html - 导航菜单不会水平排列

标签 html css html-lists

我正在尝试获得一个水平导航栏,但我无法让它正常工作。

http://jsfiddle.net/2fkxx/

nav {
    text-align: center;
}
    nav ul {
        margin: 0;
        padding: 0;
        list-style: none;
        display: inline-block;
    }
        nav ul li {
            display: inline;
        }
            nav ul li a {
                text-decoration: none;
                display: block;
                width: 80px;
            }

最佳答案

将您的 li 设置为 inline-block 而不是 inline

nav ul li {
    display: inline-block;
}

Fiddle

关于html - 导航菜单不会水平排列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22404921/

相关文章:

html - 两行里的元素。第二行没有边距

html - 奇怪的 <li> 行为

javascript - 无法读取未定义的属性 'fontWeight'

css - 旋转木马 Bootstrap 中的拉伸(stretch)图像

html - 如何使响应式导航菜单保持在页面顶部?

html - 如何重置输入的默认样式 [type ="text"] :focus in Chrome and Safari?

javascript - 在基于 css 的选项卡结构中打开特定选项卡

html - 整体底线较大的CSS div

javascript - 需要禁用下拉菜单的淡出功能(仅)

css - <UL> 和 <LI> 样式没有固定宽度的问题