【发布时间】:2014-06-29 05:44:55
【问题描述】:
我想在 css 中使用 display:inline-block 使我的导航居中?
nav {
position: fixed;
width: 100%;
}
nav ul {
width: 100%;
margin: auto;
}
nav ul li {
display: inline-block;
margin: 5px 20px 5px 20px;
text-align: center;
}
【问题讨论】:
-
必须在父级上设置内联框的文本对齐才能在中间看到它们:=
-
您需要在要设置样式的每个元素后使用逗号: 示例:
nav, ul, li, a { text-decoration: none; }希望这是错误所在。希望这可以帮助! @user3606785 -
@GCyrillus 谢谢你 :^]