应用填充时,内联块元素将下降到第二行

时间:2016-06-15 03:41:55

标签: html css list line

如标题所示,内联块列表项元素将下降到第二行。我如何将它们全部保持在中心位置并保持在同一条线上?谢谢! 下面我发布了完整的css代码和图片。

CSS:

body {
    margin: 0;
}

nav {
    position: fixed;
    background-color: #000000;
    width: 100%;
    margin: 0;
}

nav .container {
    display: table;
    margin: 0 auto;
}

nav .container ul {
    margin: 0;
}

nav .container ul li {
    list-style: none;
    color: #FFFFFF;
    display: inline-block;
    margin: 0;
    padding: 0;
}

nav .container ul li:nth-child(1n+2) {
    margin-left: 5%;
}

Image Here

2 个答案:

答案 0 :(得分:1)

如果事情不明确,请随时问我。

mongoose.connect("mongodb://localhost/restful_blog_app");

不知道但是下划线在黑色背景下给我带来了很多麻烦。如果要删除它,请将其添加到css中。 (但你可能知道)

nav .container {
    display: block;
    text-align: center;
    padding: 5px;
}

答案 1 :(得分:0)

您必须进行一些CSS更改才能获得它。请尝试下面的CSS,它的工作原理

    body {
    margin: 0;
}

nav {
    position: fixed;
    background-color: #000000;
    width: 100%;
}


nav .container ul {
  display: table;
  width: 100%;
}

nav .container ul li {
    list-style: none;
    color: #FFFFFF;
    display: table-cell;
  text-align: center;
}

nav .container ul li:nth-child(1n+2) {
    margin-left: 5%;
}