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

时间:2019-08-12 02:03:05

标签: html css

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

我尝试了不同的页边距,伸缩方向和填充。

application/json
* {
  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;
}

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

1 个答案:

答案 0 :(得分:0)

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

我添加了标题中写的内容,这降低了资产净值。

顺便说一句,在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>