views:

19

answers:

2

I'm making a Google Chrome plugin. Therefore, the injected CSS need only work in webkit. What is the webkit-specific way of clearing floats?

By clearing floats, I mean make a parent element enclose all floating children contained within.

+1  A: 

If you don't need to care about the IE bugs, you can make a clearing style (for an element not to take up space) as simple as:

.Clear { clear: both; height: 0; }

as comparison, a style that takes the IE one-character-height bug into acount would be:

.Clear { clear: both; height: 0; overflow: hidden; }

An alternative to adding a clearing tag, is to set an overflow style on the parent element of the floats, that will make it contin it's children. You can for example use overflow:hidden but without specifying a size, that way the parent will be sized by it's children.

Guffa
+1 for overflow:hidden.If you do require IE then it needs as hasLayout fix such as zoom.
RyanP13
A: 

display: inline-block did the trick.

Eric