CSS causing an UL to be indented too much in IE

2019-02-08 09:31发布

I have a navigation bar at the top of a page. In FF and Chrome the navigation bar displays fine. However in IE8 (with or without compatibility) the UL seems to indent from the left hand side, not each li just the whole li; despite declaring

text-align:center; width:600px; margin:auto; padding-left:0;

Any ideas what could be causing this?

4条回答
该账号已被封号
2楼-- · 2019-02-08 10:22

Using list-style-position:outside; specifically for IE6/IE7 worked for me. However, note that this may only be necessary if you're using list-style-position:inside; for other browsers and simply hiding the default list margin/padding by setting them to 0. Working with IE requires some finesse, and a lot of browser-specific CSS.

查看更多
爷、活的狠高调
3楼-- · 2019-02-08 10:24

I just used ul { list-style-position:outside; } to fix the indent in IE.

查看更多
相关推荐>>
4楼-- · 2019-02-08 10:28
margin-left:0px;

In Firefox the UL is padded left by default, in IE it has a left margin.

Example:

<html>
<head>
<style>

ul{
border:1px solid red;
margin:0px;
list-style:none;
padding:0px;
}

li{
border:1px solid green;
margin:0px;
}

</style>
</head>
<body>

<ul>
<li>this</li>
<li>that</li>
<li>these</li>
<li>those</li>
</ul>

</body>
</html>
查看更多
\"骚年 ilove
5楼-- · 2019-02-08 10:30

I think it should be:

ul { padding: 0; margin: 0 } 
li { padding: 0; }
查看更多
登录 后发表回答