【问题标题】:Navigation bar keeps hiding my body content导航栏一直隐藏我的正文内容
【发布时间】:2021-07-06 02:45:23
【问题描述】:

我试图建立一个网页,我从网上找到的一些 css 开始。 当我尝试在正文中添加新 div 时,它一直出现在导航栏下方。 我知道这与职位有关,但我无法找到解决方案。

wrapper{
background: #171c24;
position: fixed;
width: 100%;
}
.wrapper nav{
position: relative;
display: flex;
max-width: calc(100% - 200px);
margin: 0 auto;
height: 70px;
align-items: center;
justify-content: space-between;
}
nav .content{
display: flex;
align-items: center;
}

https://jsfiddle.net/24d1keht/

抱歉,我无法在此处发布所有代码。谢谢。

【问题讨论】:

    标签: html css


    【解决方案1】:

    将 body 的 margin-top 属性设置为导航栏的高度,然后将导航栏的绝对位置设置为页面的最顶部(因此它不受新边距的影响), top 属性。

    CSS 看起来像这样:

    body {
        margin-top: 0;
    }
    
    .wrapper {
        top: 0;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-08-05
      • 2020-11-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-31
      • 2022-09-30
      • 1970-01-01
      相关资源
      最近更新 更多