Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Triggering haslayout in IE 6, what's the side effect of using * html div { height: 1%; }

Tags:

For a while, I've been putting * html div { zoom: 1; } in my base stylesheet, and it has worked great. However, I now run into situations where there're elements that are absolute positioned that are losing their heights and widths in IE 6 cuz of this. So I'm thinking of putting * html div { height: 1%; } instead, but what are the side effects?

Update:

Thanks for all your responses. The answer is most probably no side effects as all of you said.

I will however have to disagree with all your recommendations (at this given moment) about how/when to trigger haslayout. I see haslayout a desirable behaviour and should therefore be a default behaviour in IE6 (& 7).

It's been mentioned that it's unlikely there would be any side effects, for the exact reason, why not make it a default behaviour and only turn it off when an undesirable behaviour (if ever) occurs.

One can do this by specifying {zoom: auto;} or {height:auto;} on that specific element depending on how it was defined in the base stylesheet.

I will have to give the answer to the first person that said "no side effects" since everyone's answer is the same, while some went out of scope. Thanks again!

like image 650
mike in africa Avatar asked Feb 26 '09 18:02

mike in africa


People also ask

How to increase size of div according to its content?

Using inline-block property: Use display: inline-block property to set a div size according to its content.

Why does my div have no height?

The reason why the height or the containers is 0 is because you are floating all the content inside them and floated elements don't expand the height (or width) of their parents.


1 Answers

This is known as The Holly Hack. As far as I know, there isn't a side effect, especially if you * html it for IE6 directly. I agree with the other posters that placing it on the <div> tag may not be the wisest choice - I'd target the individual elements that are causing grief.

like image 106
Mark Hurd Avatar answered Sep 22 '22 14:09

Mark Hurd