无法居中

Can't center this

我尝试将导航段落居中,但它不会居中。我现在已经尝试了很多东西,但找不到结果。

这是我的 CSS :

header {
  background: #444444;
  z-index: 100;
  transition: height 600ms 0s ease;
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  color: #ffffff;
}

#head {
  font-family: quicksand;
  text-align: center;
}

nav {
  background: #333333;
  position: fixed;
  top: 82px;
  right: 0;
  left: 0;
  color: #ffffff;
}

.navs {
  font-family: quicksand;
  font-size: 18px;
  text-align: center;
  display: inline-block;
}

a,
a:link,
a:visited,
a:hover {
  text-decoration: none;
  color: white;
  font-family: quicksand
}

#left {
  margin-right: 15px;
}

Here is my HTML :
<header>
  <h1 id="head">Resume - Mathias Nicolajsen</h1>
</header>
<nav>
  <a href="diagonaler.html"><strong><p class="navs" id="left">Projecter</p></strong></a>
  <strong><p class="navs">Omkring mig</p></strong>
</nav>
<p>Lavet af Mathias Nicolajsen</p>

我该怎么做?

header {
  background: #444444;
  z-index: 100;
  transition: height 600ms 0s ease;
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  color: #ffffff;
}

#head {
  font-family: quicksand;
  text-align: center;
}

nav {
  background: #333333;
  position: fixed;
  top: 82px;
  right: 0;
  left: 0;
  color: #ffffff;
  text-align: center;
}

.navs {
  font-family: quicksand;
  font-size: 18px;
  text-align: center;
  display: inline-block;
}

a,
a:link,
a:visited,
a:hover {
  text-decoration: none;
  color: white;
  font-family: quicksand
}

#left {
  margin-right: 15px;
}
<header>
  <h1 id="head">Resume - Mathias Nicolajsen</h1>
</header>
<nav>
  <a href="diagonaler.html"><strong><p class="navs" id="left">Projecter</p></strong></a>
  <strong><p class="navs">Omkring mig</p></strong>
</nav>
<p>Lavet af Mathias Nicolajsen</p>

尝试添加text-align: center

只需将 text-align: center; 添加到 nav { } 即可使元素居中。

试试这个。只有 text-align: center; 你的问题才会得到解决。

header {
  background: #444444;
  z-index: 100;
  transition: height 600ms 0s ease;
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  color: #ffffff;
}

#head {
  font-family: quicksand;
  text-align: center;
}

nav {
  background: #333333;
  position: fixed;
  top: 82px;
  right: 0;
  left: 0;
  color: #ffffff;
  text-align: center;
}

.navs {
  font-family: quicksand;
  font-size: 18px;
  text-align: center;
  display: inline-block;
}

a,
a:link,
a:visited,
a:hover {
  text-decoration: none;
  color: white;
  font-family: quicksand
}

#left {
  margin-right: 15px;
}
<header>
  <h1 id="head">Resume - Mathias Nicolajsen</h1>
</header>
<nav>
  <a href="diagonaler.html"><strong><p class="navs" id="left">Projecter</p></strong></a>
  <strong><p class="navs">Omkring mig</p></strong>
</nav>
<p>Lavet af Mathias Nicolajsen</p>

只需将您的 nav 替换为以下内容 CSS

nav {
        background: #333333;
        position: fixed;
        top: 82px;
        right: 0;
        left: 0;
        color: #ffffff;
        text-align: center;
    }