CSS causing an UL to be indented too much in IE

人走茶凉 提交于 2019-12-18 15:01:04

问题


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?


回答1:


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>



回答2:


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




回答3:


I think it should be:

ul { padding: 0; margin: 0 } 
li { padding: 0; }



回答4:


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.



来源:https://stackoverflow.com/questions/1184770/css-causing-an-ul-to-be-indented-too-much-in-ie

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!