Miguel
Miguel

Reputation: 1887

CSS max-width not working

I have this code, but strangely the max-width and with property are not working:

HTML:

<body>
    <img src="imgs/topBar.png">
    <div id ="wrapper">
    </div>
</body>

CSS:

body {
    padding: 0;
    margin: 0;
}
body img:first-child{
    width: 100%;
    height: 5px;
    margin:0;
    display: block;
}
#wrapper {
    width: 100%;
    max-width: 1200px;
    height: 100px;
    margin: 0 auto;
    border: 4px solid;
}

I made a http://jsfiddle.net/vkdbq/

Upvotes: 3

Views: 21353

Answers (1)

Mastrianni
Mastrianni

Reputation: 3920

You can set:

#wrapper {
    -webkit-box-sizing: border-box; /* Safari, other WebKit */
    -moz-box-sizing: border-box;    /* Firefox, other Gecko */
    box-sizing: border-box;         /* Opera/IE 8+ */

    width: 100%;
    max-width: 1200px;
    height: 100px;
    margin: 0 auto;
    border: 4px solid;
}

Upvotes: 7

Related Questions