why does the containing div not recognize the height of the items within? [duplicate]
how can my containing div (boxes_blue) recognize the height of the items within?
#boxes_blue {
display: block;
margin: 0 0 0 175px;
border: 1px solid brown;
clear: both;
}
#boxes_blue_each {
float: right;
height: 100px;
width: 100px;
padding: 10px;
border-left: 3px solid #fff;
background-color: #004964;
color: #fffacf;
text-transform: uppercase;
text-align: left;
}
<div id="boxes_blue">
<div id="boxes_blue_each">one</div>
<div id="boxes_blue_each">two two</div>
<div id="boxes_blue_each">three three three</div>
<div id="boxes_blue_each">four four four four</div>
</div>
This is happening because the divs that are contained all floated.
I am not sure why this is the way it is, but I know of a few solutions. Either set the containing div to have "overflow:hidden", or add another div below the floated divs with "clear:both". You could also, of course, set the height and width of the containing div as well.
精彩评论