How can i prevent taking div out of the normal flow but still using float, like this:
<div id="one">
<div id="two"></div>
</div>
CSS:
#one {
width: 100%;
height: auto;
}
#two {
width: 100px;
height: 100px;
position: relative;
float: left;
}
Now div "one" has no height and div "two" just looks like it isn't in the first div.
You're seeing your dive #one collapse. Adding an overflow value to the CSS for that element should fix this problem.
Ahh, the collapse problem. There's an excellant article about floats here http://css-tricks.com/all-about-floats/ In your case, I'd add
to
#one
The relative info is quoted below:
This should solve your problem. Try adding it to both DIVs:
**For the sake of testing, you might want to add some background color.
jsFiddle example here!