【发布时间】:2021-02-08 23:27:03
【问题描述】:
我的导航栏没有正确居中,这让我抓狂——左侧的空白区域稍微多一些。非常感谢你。这是代码
HTML:
<div class="navbar">
<ul class="navitems">
<li>
<a class="current" href="index.html">Home</a>
</li>
<li>
<a href="podcasts.html">Podcasts</a>
</li>
<li>
<a href="articles.html">Articles</a>
</li>
<li>
<a href="merch.html">Merch</a>
</li>
<li>
<a href="aboutus.html">About Us</a>
</li>
</ul>
</div>
CSS:
body {
margin:0
}
.navbar {
text-align: center;
border: 1px solid black;
width: 100%;
margin-left: auto;
margin-right: auto;
}
.navitems ul {
list-style: none;
}
.navitems li {
display: inline-block;
padding-top: 1.5%;
padding-bottom: 1.5%;
padding-right: 3%;
padding-left: 3%;
border: 1px solid blue;
width: 12%;
font-size: 20px;
}
.navitems a {
color: black;
text-decoration: none;
font-family: georgia;
}
.navitems li:hover a{
transition: all ease-in-out .5s;
color: #f88122;
text-decoration: underline;
}
【问题讨论】:
标签: html css navbar centering navigationbar