Div height:0px不起作用? [英] Div height:0px does not work?
问题描述
<div style="height:0px;max-height:0px">
</div>
将div高度设置为0px似乎无效。
Setting a div height to 0px does not seem to work.
div扩展以显示其内容,我们如何防止这种情况发生?
The div expands to show its contents, how do we prevent this from happening?
推荐答案
如果你想要确保它没有高度,你可以使用这样的:
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;
如果您在IE上仍遇到问题,您还可以添加
If you're still having problems on IE, you could also add
zoom: 1;
到一个以条件注释为目标的样式表中。这将触发IE中的hasLayout属性。
to it in a stylesheet targeted at IE with a conditional comment. That'll trigger the hasLayout property in IE.
并且显示:none与将其设置为零高度不同。只需查看各种clearfix解决方案,不是从流程中删除它是至关重要的。
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.
这篇关于Div height:0px不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!