导航栏链接位置未在图像下方居中



我是一个非常新的程序员,正在为 FCC 开发一个产品登陆项目,目前正试图在徽标图像下对齐导航链接。css的某些部分是混乱或空白的,因为我一直在尝试。

我尝试了不同的边距、弹性方向和填充。

* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.wrapper {
position: relative;
}
li {
list-style: none;
}
a {
color: #000;
text-decoration: none;
}
#header-img {
display: flex;
max-width: 75rem;
width: 45rem;
justify-content: center;
align-items: center;
text-align: center;
}
header {
position: fixed;
top: 0;
min-height: 7.5rem;
padding: 0rem 2rem;
display: flex;
justify-content: space-around;
align-items: center;
background-color: #A9A9A9;
}
nav {
width: 100%;
margin: ;
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
padding: 0 5rem;
}
nav>ul {
width: 35vw;
display: flex;
flex-direction: row;
justify-content: space-around;
}
<div class="wrapper">
<header id="header">
<div class="logo">
<img id="header-img" src="https://i.imgur.com/G5nVsYG.png" alt="ar-15 logo" />
</div>
<nav id="nav-bar">
<ul>
<li><a class="nav-link" href="#points">What seperates us</a></li>
<li><a class="nav-link" href="#put-together">How to build</a></li>
<li><a class="nav-link" href="#product-price">Current Product Deals</a></li>
</ul>
</nav>
</header>

我希望导航链接在图像下方。

添加到标题标签 'flex-wrap: wrap;'

我添加了我在标题中写的内容,它降低了 NAV。

顺便说一下,在CSS中你应该使用Class。

* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.wrapper {
position: relative;
}
li {
list-style: none;
}
a {
color: #000;
text-decoration: none;
}
#header-img {
display: flex;
max-width: 75rem;
width: 45rem;
justify-content: center;
align-items: center;
text-align: center;
}
header {
position: fixed;
top: 0;
min-height: 7.5rem;
padding: 0rem 2rem;
display: flex;
flex-wrap: wrap;
justify-content: space-around;
align-items: center;
background-color: #A9A9A9;
}
nav {
width: 100%;
margin: ;
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
padding: 0 5rem;
}
nav > ul {
/*     width: 35vw; */
display: flex;
flex-direction: row;
justify-content: space-around;
} 
nav ul li {
padding: 10px 10px;
}
<div class="wrapper">
<header id="header">
<div class="logo">  
<img id="header-img" src="https://i.imgur.com/G5nVsYG.png" alt="ar-15 logo" />            
</div>    
<nav id="nav-bar">
<ul>
<li><a class="nav-link" href="#points">What seperates us</a></li>
<li><a class="nav-link" href="#put-together">How to build</a></li>
<li><a class="nav-link" href="#product-price">Current Product Deals</a></li>
</ul>
</nav>
</header>

最新更新