Internet Explorer 8中的LI元素

3

由于某些原因,我的LI元素在Internet Explorer中没有向左浮动,它们会一个接一个地显示。有人知道我该如何解决这个问题吗?

#books ul{
    list-style:none;
    margin:0px;
    float:left;
    display:inline;
}
#books ul li{
    float:left;
    margin-right: 20px;
    padding-bottom: 20px;
    height:300px;
    display:inline;
}

你能提供HTML和CSS吗?它在其他浏览器中工作吗?等等。 - Jonathan Fingland
我在问题中添加了CSS。是的,在Firefox中它运行得很好。 - ryudice
1
你是否正在使用兼容性视图? - Robert Harvey
2个回答

4
如果我正确理解您的问题,可能与设置display:inline有关。在IE和FF中更改为display:block;似乎可以解决该问题。
#books ul{
list-style:none;
margin:0px;
float:left;
display:block;}

#books ul li{ 浮动:left; 右边距: 20像素; 底部填充: 20像素; 高度:300像素; 显示:block; }

3
它们默认已经被阻止,所以我只需删除整个属性。 - BalusC

0

如果你只是想让每个LI在同一行显示,那么就没有必要使用float,你可以仅使用display属性。

#books ul{
    width: 100%;
    list-style: none;
    margin: 0px;
}
#books ul li{
    margin-right: 20px;
    padding-bottom: 20px;
    height: 300px;
    display: inline-block;
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接