我想给我的头一个z索引,但每次我把它放在头被完全摧毁和idk我可以修复它. 另外,我的框重叠了我的navbar/header,我可以用z索引修复它吗?

body {
  background-color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
}

.header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  padding: 19px 20px;
  background: #DCdCdC
}

.logo {
  position: fixed;
  top: -10px;
  font-size: 32px;
  padding: 20px 20px;
  color: #fff;
  text-decoration: none;
  font-weight: 650;
}

.navbar a {
  font-size: 18px;
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  margin-left: 400px;
  word-spacing: 2px;
  z-index: 1;
}

.products .box-container {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.products .box-container .box {
  flex: 1 1 30rem;
  box-shadow: 0 .5rem 1.5rem rgba(0, 0, 0, .1);
  border-radius: .5rem;
  border: .1rem solid rgba(0, 0, 0, .1);
  position: relative;
  transition: 1s;
  z-index: 0;
}

.products .box-container .box .image {
  position: relative;
  text-align: center;
  padding-top: 2rem;
  overflow: hidden;
}

.box:hover {
  transform: scale(1.05);
  z-index: 0;
}

.products .box-container .box .image .icons {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
}

.products .box-container .box .image .icons a {
  margin-left: 8rem;
  margin-bottom: -3rem;
  height: 4rem;
  line-height: 6rem;
  font-size: 1.25rem;
  width: 50% background: black);
  color: #000;
}

.products .box-container .box .content {
  padding: 2rem;
  text-align: center;
}

.products .box-container .box .content h3 {
  font-size: 2rem;
  color: #000;
}

.products .box-container .box .content price {
  font-size: 1.5rem;
  color: black;
  font-weight: bolder;
  padding-top: 1rem;
}
<div class="header">
  <a href="1-Seite.html" class=l ogo>fashion</a>
  <nav class="navbar">
    <a href="1-Seite.html">Home</a>
    <a href="2-Seite.html">Shop</a>
    <a href="#">Über uns</a>
  </nav>
</div>
<section class="products" id="products">
  <h1 class="heading"> latest <span> products</span> </h1>
  <div class="box-container">
    <div class="box">
      <div class="image">
        <img src="bb.hoodie.png" width="50%;" id="box" alt="">
        <div class="icons">
          <a href="#" class="fas fa-heart"></a>
          <a href="#" class="cart-btn">add to cart</a>
          <a href="#" class="fas fa-heart"></a>
        </div>
      </div>
      <div class="content">
        <h3>MEDIUM FIT B HOODIE</h3>
        <div class="price"> 1.225€ <span></span> </div>
      </div>
    </div>
    <div class="box">
      <div class="image">
        <img src="bbjacke.png" width="50%;" id="box" alt="">
        <div class="icons">
          <a href="#" class="fas fa-heart"></a>
          <a href="#" class="cart-btn">add to cart</a>
          <a href="#" class="fas fa-heart"></a>
        </div>
      </div>
      <div class="content">
        <h3>RACING JACKET</h3>
        <div class="price"> 3.100€ <span></span> </div>
      </div>
    </div>
    <div class="box">
      <div class="image">
        <img src="nfs.hose.png" width="50%;" alt="">
        <div class="icons">
          <a href="#" class="fas fa-heart"></a>
          <a href="#" class="cart-btn">add to cart</a>
          <a href="#" class="fas fa-heart"></a>
        </div>
      </div>
      <div class="content">
        <h3>HEAVY WASHED BOMBER</h3>
        <div class="price">2.175€ <span></span> </div>
      </div>
    </div>
    <div class="box">
      <div class="image">
        <img src="nfs.bomber.png" width="50%;" alt="">
        <div class="icons">
          <a href="#" class="fas fa-heart"></a>
          <a href="#" class="cart-btn">add to cart</a>
          <a href="#" class="fas fa-heart"></a>
        </div>
      </div>
      <div class="content">
        <h3>GREY INSIDE OUT BOMBER</h3>
        <div class="price"> 2.750€ <span></span> </div>
      </div>
    </div>
    <div class="box">
      <div class="image">
        <img src="ro.coat.png" width="50%;" alt="">
        <div class="icons">
          <a href="#" class="fas fa-heart"></a>
          <a href="#" class="cart-btn">add to cart</a>
          <a href="#" class="fas fa-heart"></a>
        </div>
      </div>
      <div class="content">
        <h3>HOODED COAT GREY/BLACK </h3>
        <div class="price"> 4.250€ <span> </span> </div>
      </div>
    </div>
    <div class="box">
      <div class="image">
        <img src="ro.coat 2.png" width="50%;" alt="">
        <div class="icons">
          <a href="#" class="fas fa-heart"></a>
          <a href="#" class="cart-btn">add to cart</a>
          <a href="#" class="fas fa-heart"></a>
        </div>
      </div>
      <div class="content">
        <h3>HOODED COAT BLACK</h3>
        <div class="price"> 4.250€ <span> </span> </div>
      </div>
    </div>
  </div>

推荐答案

首先,你在第88行到第90行的代码中有一些错误.

虽然我不能解决你的第一个问题,我可以回答你关于z索引和你的框重叠导航栏/标题的问题.如果你想让你的"盒子"在导航栏/标题下重叠(相反重叠),那么是的,你可以使用Z索引.如果你想在下面使用它,那么你必须使用break或其他HTML组件.您也可以使用与位置相关的CSS组件.(请注意,Z—Index并不是唯一的方法来使某些东西不重叠)

Html相关问答推荐

弹性项在主轴方向溢出

Blazor中有1像素高行的表格

使用Scrapy Select 最后一个子文本

如何在图像中垂直和水平居中显示文本?

窗口视图之外的下拉菜单位置

如何保持嵌套进度条的背景色?

CSS Grid:使网格行填充屏幕,将下一行推离屏幕

Html视频标签:圆角像素化

为什么字体大小而不是 colored颜色 属性适用于元素?

如何使粘性导航栏能够跨其他组件工作?

在选项标签中如何添加Django模板的条件

实验的响应式屏幕尺寸

是否可以为长 huxtable 固定头部?

Mediawiki css/html 信息框创建空白行

如何让 backdrop-filter: blur() 效果在 iOS 上运行?

我正在使用 react-router-dom 并创建了一个固定的导航栏,它在每个网页上不断改变大小,我不知道为什么

如何将第一个 p 标签放在其下方第二个 p 标签的中间

使用 htmloutput 在shiny 的应用程序中呈现文本

SVG 适用于 Safari,不适用于 Chrome

无法使用 Reactjs 多次更新本地存储