html - 将导航栏居中

标签 html css ajax

嘿伙计们,我有一个标准的导航栏,它有一个无序列表并使用 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/

相关文章:

html - 整个布局搞砸了相对宽度

html - 换行符 <hr> 未按预期呈现

jquery - 如何在ajax调用中使用jquery中的三元运算符?

javascript - Select2.js v4.0 : How transmit filter text to ajax source data?

jquery - CSS 三 Angular 形箭头菜单事件项

html - 无法让不透明的文本覆盖仅向右滑动

javascript - div 和位置之间共享 100vh :sticky navbar

html - bg-info 不适用于 bootstrap 中的全身

javascript - 使用ajax和php向MySQL插入数据

javascript - 绝对位置和相对位置都不好用