
Originally Posted by
kuau
Dear B: Thanks so much... great information! I have never ventured into this part of css... been out to lunch I guess LOL. I haven't had time to try anything yet, but I'm just wondering if making a site mobile-friendly will screw up the desktop version (?).
Not really - you can retro-fit a desktop layout to make it fit narrower screens.
You may have heard of the term "mobile first" on your web travels, which (amongst other things pertaining to performance, accessibility and usability that I won't go in to here) means that a site has been developed with a narrow, linear layout in mind first; all default CSS for a site that looks and works nicely in mobile proportions comes at the top of a style sheet, then, media queries are added to target progressively wider screens (whenever your layout needs adjusting);
Code:
/* default skinny screen CSS here */
@media ( min-width:35em ) {
/* CSS for screens that are wider than 560px */
}
@media ( min-width:50em ) {
/* CSS for screens that are wider than 800px */
}
@media ( min-width:64em ) {
/* CSS for screens that are wider than 1024px */
}
You can use px or other units for media queries, although it's preferable to use relative units (ems) due to more predictable browser scaling. Useful info here http://bradfrost.com/blog/post/7-hab...ries/#relative The default font-size for browsers tends to be 16px so you work out your desired em value by dividing the number of target pixels by 16 (1024px / 16px = 64em)
Anyway, the above media queries are for a mobile first approach. But you can use them in reverse to tackle a desktop layout that progressively downscales to narrower tablet then mobile widths;
Code:
/* wide desktop CSS here */
@media ( max-width:60em ) {
/* CSS for screens that are narrower than 960px */
}
@media ( max-width:50em ) {
/* CSS for screens that are narrower than 800px */
}
@media ( max-width:37.5em ) {
/* CSS for screens that are narrower than 600px */
}
This is one of the ways to work a desktop layout backwards so that it becomes size-appropriate for mobiles.
Be aware that the retro-fitting/reverse approach usually leads to more CSS overrides and therefore bigger stylesheets, plus a greater use of display:none;
to hide content that doesn't "work" on mobile.
Menus can be challenging too so you might find some useful info here http://bradfrost.com/blog/web/responsive-nav-patterns/
Hope that helps
Bookmarks