Displays MindShare content at 50% width if browser width > 720px (45em)
Loading stylesheets based on media features
- or -
@import url(/medium-width.css) screen and (min-width:800px) and (max-width:1280px);
- or -
Viewports: adapting to mobile screen sizes
The viewport meta tag
Without this most mobile browsers will use a screen width of 980px.
Controlling viewport scale
Min / Max scale
Preventing scale
Generally preventing user scaling of your page should be avoided, but is sometimes used
to with Mobile Safari to prevent the page zooming in when you rotate to landscape orientation.
Even if the screen size causes the display:none to be active remember that all the content
in that container will still be fetched (images, etc.). It just won't be displayed. This is
an issue for mobile users if your page contains lots of content that will be hidden for
mobile users.
Adds limited media query support for browsers that don't support them.
Note Respond.js supports only min-width and max-width media queries.
@media screen and (min-width: 480px){
...styles for 480px and up go here
}
Obviously this adds some overhead as the JS file must be loaded and the CSS file parsed before
IE can continue. Conditional comments may be more performant, if not less flexible.
if (window.matchMedia("(min-width: 400px)").matches) {
/* the view port is at least 400 pixels wide */
} else {
/* the view port is less than 400 pixels wide */
}
Or use properties like window.innerWidth and window.devicePixelRatio
Support: window.matchMedia is supported in IE10 and later.
Responsive Layouts
Proportional Sizing - percentage based layout
Introduction of additional elements as screen real estate increases. Often referred to as 'adaptive' content.
Note the number 100w in this case refers to the max-width
Browsers aggressively fetch ahead the file in the "src" attribute is likely to be fetched
while the Javascript is loading. Put small images in this default attribute or leave the
src attribute off entirely.