Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

<div style="height:0px;max-height:0px">
</div>

Setting a div height to 0px does not seem to work.

The div expands to show its contents, how do we prevent this from happening?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
447 views
Welcome To Ask or Share your Answers For Others

1 Answer

If you really want to be sure it's gonna be have no height you could use something like this:

display: block;
line-height:0;
height: 0;
overflow: hidden;

If you're still having problems on IE, you could also add

zoom: 1;

to it in a stylesheet targeted at IE with a conditional comment. That'll trigger the hasLayout property in IE.

And display:none isn't the same as setting it to zero height. Just look at the various clearfix solutions for a case where not removing it from the flow is crucial.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...