Is it possible to let the parent of a float grow with the float even when the float has more content than the parent block?
Let me give an example
<div>
<div style="float right; width 100px">Lots of content. Lots of content. Lots of content...</div>
Some content
</div>
What happens is that the float crosses the border of the outter block.
The inner div is typically a floated image. Lets say the outter div has some kind of border. Wouldn't it be nicer if the border grew to span the entire image too?
I know the "clear" property kan be used to keep other blocks "on distance", but I don't know if it can be used on the containing block's border/margin.
Keeping float within parent block
Is the attached file what you're looking for?
Keeping float within parent block
Exactly. Almost.
Because I would classify this as a hack, and hacks are no-nos. Is this a solution used in general for this kind of problem. I'm interested in links to major CSS sites with an explanation on this.
Thanks for helping me out!
Keeping float within parent block
It's not a hack, but extra, purely presentational markup (as you're only using this spacer div to expand the float's container, rather than for presentation of the content in the spacer div itself (of which there is none! ), which I also try to avoid where possible.
According to the specs for clear, "This property indicates which sides of an element's box(es) may not be adjacent to an earlier floating box." - so you have a div and you say clear: both, so neither side of this box can be beside a float, therefore the box will be positioned below the float.
A link of interest:
http://css-discuss.incutio.com/?page=ClearingSpace
Argument accepted
Ok, I'll give you credit for that one..
We're in some kind of greyzone here, but I can live with it since it's compatible with most browsers and lack of compatibility don't ruin the looks of the site. And, it doesn't mess up my code too much because I won't use it more than necessary.
Disclaimer: I don't want to be responsible for neither holy- nor unholy wars, that's why I write this disclaimer. BTW: When was the last time somebody escaped any responsibility by writing a disclaimer?
Re: Argument accepted
Ok, I'll give you credit for that one..
Sorry, just had to satisfy my sig.
The sig demands satisfaction... *ahem*, er......