如何在导航栏中的文本居中HTML和CSS?

问题描述

我在网站导航栏中将文本水平居中时遇到麻烦。我已经看到了解决方法,但是我一直尝试的所有方法都无法正常工作。我是HTML和CSS的初学者。这是我的CSS和HTML:

.topnav {
  overflow: hidden;
}

.topnav a {
  float: left;
  display: block;
  color: white;
  text-align: center;
  text-transform: uppercase;
  font-weight: bold;
  font-family: 'Poppins',sans-serif;
  padding: 15px;
  text-decoration: none;
  align-items: center;
}

.topnav a:hover {
  color: black;
}
<div class="topnav">
  <a href="homepage.html">Home</a>
  <a href="aboutme.html">About Me</a>
  <a href="differentservices.html">Different Services</a>
  <a href="personalwork.html">My Personal Work</a>
  <a href="customerwork.html">My Customer Work</a>
  <a href="reviews.html">Customer Reviews</a>
  <a href="pricing.html">Pricing</a>
  <a href="contact.html">Contact Me</a>
</div>

我知道我的CSS中不应该包含“ float”,但是其余的我都遇到了麻烦。任何帮助将不胜感激!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)