Last Updated: February 25, 2016
·
1.293K
· cironunes

Don't use width in your .wrapper

When you do something like that:

.wrapper {
    width: 960px;
    margin: 0 auto;
}

The only problem:
when we have a narrowed window like in mobile devices and the width of block-level elements - like the div you applied the .wrapper class - is too large the browser creates a horizontal scroll and "respect" the width of the element.

Why don't stop use widths and just "limit" the area of your .wrapper?

.wrapper {
    max-width: 960px;
    margin: 0 auto;
}

This way you don't need to worry about evil scrolls or browser support. It is supported by major browsers:
http://caniuse.com/#search=max-width

PS.: Inspect this page .wrapper and see it working

3 Responses
Add your response

cool !

over 1 year ago ·

All is perfect, BUT(T) - <IE8 is a pure evil.. so you always need additional code, based on the device width OR browser. So which could preferable - <!-- IE --> hacks with inline/additional file css, or media queries, so you get the modern browsers?

That is if I have indeed understood your tip though ;)

over 1 year ago ·

@nickeyz: I think you misunderstood the tip.

The main idea is use max-width to "be responsive".
About media queries, you can use together with the max-width.

Have I answered your question? :)

over 1 year ago ·