Div height:0px does not work?

后端 未结 10 1319
既然无缘
既然无缘 2020-12-05 04:42

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

The div expands to show it

10条回答
  •  余生分开走
    2020-12-05 04:52

    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.

提交回复
热议问题