Reputation: 3063
for some reason the #CCC background (100% width) doesn't show up with my code below. Would you know why? Tks
.wrap100pc {
width: 100%;
margin: auto;
background: #ccc;
}
#bottom-left {
float: left;
width: 490px;;
background: #5421c2;
height: 300px;
}
#bottom-right {
float: right;
width: 490px;;
background: #2ec4a6;
height: 300px;
}
.clear:after {
clear: both;
}
<div class="wrap100pc clear">
<div id="bottom-left">bottom-left</div>
<div id="bottom-right">bottom-right</div>
</div> <!-- End DIV Wrap100pc Clear-->
Upvotes: 0
Views: 4932
Reputation: 663
You need to specify a height
for the .wrap100pc
.
Hope that helps!
Upvotes: 1
Reputation: 11302
There is no need to add overflow:auto
to div#wrapper
. Your .clear
style definition does not fix .wrapper
height.
Changing it to:
.clear:before,
.clear:after {
content: " ";
display: table;
}
.clear:after {
clear: both;
}
solves your problem.
Upvotes: 3
Reputation: 3360
You just need to add float:left
to the wrapper too:
.wrap100pc {
width: 100%;
margin: auto;
background: #ccc;
float:left;
}
EDIT: If you don't want it floated, the other answer using overflow
would work just as well.
Upvotes: 2
Reputation: 207900
To get the background back, add overflow:auto
to your #wrapper
div.
.wrap100pc {
width: 100%;
margin: auto;
background: #ccc;
overflow:auto;
}
The floated child divs have their own block formatting context and applying overflow:auto (or hidden) produces the result you seek. For an in-depth answer about block formatting context, see How does the CSS Block Formatting Context work?
Upvotes: 2