Reputation: 90756
I have the following code to create a 1px height line:
<div style="width:300px; height:1px; background-color:#ff3300; margin-top: -1px;"></div> <!-- top red line -->
The code works fine in Firefox, however in IE8, it is displayed as a 10px height line or so. How can I force IE to take into account the specified height?
Edit:
min-height
property to 1px but that didn't work either.max-height
is ignored by IE tooline-height
to 1 doesn't helpWhy is IE ignoring all my CSS rules?
Upvotes: 2
Views: 5759
Reputation: 11
@Laurent, if you are still unable to get the desired 1px div, despite of using
height:1px; line-height:1px;
font: normal 1px/1px arial; you might require to check your DTD (Document Type Definition) at the top of your webpage code. You can try this:
<!DOCTYPE HTML>
<html>
...
</html>
Upvotes: 1
Reputation: 1344
My suggestion: This is browser scroll bar problem. Just you put body{ margin:0; padding:0;} you can't see line in all browser.
IE7 scroll bar top arrow putting down that line.
Upvotes: 0
Reputation: 220
It's really hard to tell without the context... aside from resetting the padding to 0 it could have to do with other elements (probably above). Especially if they're floated. May also try clear:both; Also make sure it doesn't have display:inline; anywhere... It's block by default, and should be block.
It's really poking in the dark without the context.
Upvotes: 0
Reputation: 17285
Just set font-size to 1px; IE is limiting height of this div to font size.
Upvotes: 9