Div height solution missing in ie6

2019-05-07 11:09发布

问题:

i'm using a empty div to display a line by setting height 3px. it works fine in all browsers but in ie6 the height div displayed with 20px height. It remains same even for height:0px . But changes in other properties reflects but not height and there is no duplicate css entry and inherited value from other div. Can any one help please

<div id="line"></div>   

CSS:

#line {
    border: none;
    background-color: #134c7c;
    height: 3px;
    margin-bottom: 20px;
}

回答1:

Internet Explorer has the odd idea that the content of every element should be at least one character high. You can get around this by using the overflow attribute, that way the content can remain a character high, but it doesn't affect the height of the element itself:

.line { height: 3px; overflow: hidden; }


回答2:

Try:

line-height:0


回答3:

Just a wild guess.

Inspect whether there is any space inside the element. If yes then set the

font-size: 1px;

property of the element.



回答4:

try with space in the div or   Just guess



标签: css html height