I know what media queries are and why they are used, but I'm not sure on how the best way to develop a mobile site with them are.
Example: I have mysite.com that has a style sheet with all the necessary styles (let's say it's a pretty big file). At this point, none of my styles target lower screen resolutions or other devices.
I then decide to make a mobile version of my site. To make it easy, I'll target only iPhone users for now, and if the code detects someone visits my site on an iPhone, they get the mobile version.
My question(s): Where is the best place to include these extra styles, so that a user sees the mobile version? Should I include these styles in the original style sheet, or would it better if I separate them out into their own style sheet?
Say that my site is built entirely with floats, but my mobile version will just show every element stacked on top of each other. How do I show that using media queries? Is it as simple as declaring float:none; or something?
Basically, what I'm trying to ask in the paragraph above is, how do I construct my style sheet so that, for example, the basic colors and maybe link positions or whatever persist in the mobile version as in the desktop version but with differences such as stacking everything on top of each other in the mobile version?
Are the rules in the media query section of a style sheet basically 'over-riding' what you've declared in the non media query sections?
I've found many examples of using media queries, but I can't find one working example of a full site. If I have a mobile.css and main.css linked in the same HTML page, how do they work together to retain some aspects of my site in the mobile version but change others?
Last question: is it possible to have an entirely fixed-width design, but still use media queries? The code will still be able to detect when the browser shrinks or expands past a certain width/height, correct?
Sorry for the long and probably confusing question. I hope you can tell what I'm trying to ask.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…