嘿伙计们,我有一个标准的导航栏,它有一个无序列表并使用 Sprite 。我还使用 jquery 来渲染一些动画。一切正常。我在将栏居中时遇到问题。它向左对齐。我试过使用 text-align:center 但这不起作用。我认为存在冲突的属性。你们能帮我把它放在中心吗?我不是那么大的 UI 开发人员!
.navbar {
list-style-type: none;
list-style-position:outside;
position: relative;
margin: 0;
padding: 0; }
.navbar li{
display: block;
overflow: hidden;
padding: 0;
cursor: pointer;
float: left;
width: 125px;
height: 40px;
margin-right: 0px;
background-image:url(sprite.jpg);
background-repeat:no-repeat;
}
.navbar a{
display:block;
height:40px;
text-indent:-9999px;
outline:none;
}
最佳答案
你试过吗?
margin-left: auto;
margin-right: auto;
或者类似的东西?
margin-left: 0px;
margin-right: 0px;
关于html - 将导航栏居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3218808/