使用下面的 CSS,我可以将 ul 中的每个 li 居中。问题是我看不到 li 元素。他们在 ul 之下。我知道它们居中,因为我在 Chrome 开发者工具中看到了它。
nav ul {
-webkit-box-pack: center;
display: -webkit-box;
margin: 0 auto;
overflow: hidden;
}
nav ul li {
float: left;
list-style-type: none;
padding: 25px;
}
z-index 根本不起作用...
更新:我删除了 float: left 并且它起作用了!
谢谢。
最佳答案
尝试向 ul 添加固定高度。
关于Css 3 灵活的盒子布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5419378/