HTML、CSS : Header appears behind the other content

标签 html css header

我正在尝试做一个固定的标题,但它隐藏在屏幕上其余内容的后面。我已尝试更改 z-index,但它不起作用。

我的 html 文件如下所示:

body {
  margin: 0;
}
.header {
  width: 100%;
  height: 88px;
  position: fixed;
  left: 0;
  top: 0;
}
.content {
  margin-top: 100px;
}
.first-sec {
  width: 100%;
  height: 608px;
  background: black;
  opacity: 0.8;
}
.second-sec {
  width: 100%;
  height: 89px;
}
.third-sec {
  width: 100%;
  height: 665px;
}
.fourth-sec {
  width: 100%;
  height: 317px;
  background: rgba(40, 40, 40, 0.85);
}
<div class="header">
  <h1>HEADER</h1>
</div>
<div class="content">
  <div class="first-sec">
  </div>
  <div class="second-sec">
  </div>
  <div class="third-sec">
  </div>
  <div class="fourth-sec">
  </div>
</div>

我做错了什么?

最佳答案

你可以试试这个

.header{
z-index:2 !important;
    width:100%;
    height:88px;
    position: fixed;
    left:0;
    top:0;
    background: gray;
}

(背景:灰色仅供临时使用)

关于HTML、CSS : Header appears behind the other content,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39122792/

相关文章:

php - 将 CSS 与变量 php 结合

javascript - 如何打开保存对话框而不是在浏览器中为我的 Sharepoint 站点打开文件

c# - 需要在 asp 下拉列表中选择颜色

CSS 动画计时

html - 如何在 html 表中的一个列标题下包含 2 列?

jquery - 滚动到顶部按钮不显示

javascript - 按钮点击问题

php - 在标题中显示页面标题 - Wordpress

java - Android java http 与身份验证删除内容类型

objective-c - dequeueReusableHeaderFooterViewWithIdentifier 中的 Dequeing HeaderView 提示 IBoutlet