请我挣扎在设置我的导航栏水平的右手边。
* {
font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
padding: 0;
margin: 0;
box-sizing: border-box;
}
body {
width: 100%;
}
#header {
display: flex;
align-items: center;
justify-content: space-between;
background-color: #02082c;
color: #f9f9f9;
}
.container {
width: 85%;
margin: 0 auto;
}
.brand {}
.logo {
color: white;
text-decoration: none;
}
.navbar {
list-style: none;
display: flex;
}
.navbar .nav-list {
margin: 0 10px;
}
.navbar .nav-item {
font-weight: 600;
font-size: 18px;
}
<section id="header">
<div class="container">
<div class="brand">
<h1><a href="#" class="logo">GOLD</a></h1>
</div>
<ul class="navbar">
<li class="nav-list"><a href="#" class="nav-item">Home</a></li>
<li class="nav-list"><a href="#" class="nav-item">About Us</a></li>
<li class="nav-list"><a href="#" class="nav-item">Services</a></li>
<li class="nav-list"><a href="#" class="nav-item">Contact Us</a></li>
</ul>
</div>
</section>
请有人帮我出去。
1条答案
按热度按时间vvppvyoh1#
您已经将 flex 设置为
#header
,但所有对齐的元素都在您的.container
中。将flex-properties转移或添加到.container
就足够了。