In this example http://jsbin.com/inoka4 no width is defined for parent element
if i want to wrap red boxes in container border.
then we can make this in 5 ways
- to giving
float
also to<div class="container">
overflow:hidden
oroverflow:auto
- any clearfix hack to
<div class="container clearfix">
- Giving height to
<div class="container">
- adding one more html element (for example another
div
or<br >
) after 2 boxes in<div class="container">
enter code hereand give
clear:leftor
:bothor
:right` to that element
my question is any other option except float
do not make any changes in <div class="container">
and inner boxes width. but if we use float:left
or right
to parent box then it's shrink the whole box and inner-boxes as well.
Why?
example link: http://jsbin.com/inoka4
Edit: My question is not about which method i should use, the question is why Float shrink the width