html - Chrome - CSS - 背景大小重叠

标签 html css google-chrome background-image background-size

我无法像这样重叠背景图像:

div.test{
  position:relative;
  height: 100%;
  width: 100%;
  background-color: red
}

div.container{  
  height: 480px;
  width: 150px;
  
}

div.test:before, div.test:after{
      content: "";
    position: absolute;
    z-index: 1;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
}

div.test:before{
      background-image: linear-gradient(to bottom, #E5E5E5 1px, transparent 1px);
    background-size: 100% 15.0px;
}

div.test:after{
        background-image: linear-gradient(to bottom, blue 1px, transparent 1px);
    background-size: 100% 60px;
}
<div class="container">
  <div class="test">

  </div>
</div>

我试图重叠第 4 个条纹,但我不明白为什么它不起作用。条纹每次重复时都会变得更加分离。如果“之前”伪元素每 15 像素重复一次,如果“之后”伪元素的高度恰好是 60 像素,难道不应该将其放在第 4 个条纹上吗?

编辑:刚刚注意到这只发生在 Chrome 中:

enter image description here

这是火狐:

enter image description here

最佳答案

我不明白, strip 显示为您想要的(为了检查它,我只更新了 strip 颜色)。有什么问题吗?

div.test{
  position:relative;
  height: 100%;
  width: 100%;
  background-color: red
}

div.container{  
  height: 480px;
  width: 150px;
  
}

div.test:before, div.test:after{
    content: "";
    position: absolute;
    z-index: 1;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
}

div.test:before{
      background-image: linear-gradient(to bottom, #E5E5E5 1px, transparent 1px);
    background-size: 100% 15.0px;
}

div.test:after{
        background-image: linear-gradient(to bottom, #007ac2 1px, transparent 1px);
    background-size: 100% 60px;
}
<div class="container">
  <div class="test">

  </div>
</div>

关于html - Chrome - CSS - 背景大小重叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43839126/

相关文章:

javascript - 必须通过单击 Javascript/ReactJs 中的按钮来发送电子邮件

html - 在简单的模板菜单上添加一个 css 子菜单

css - 背景图像显示在设计 View 中但不显示在浏览器中? ( Visual Studio 2008)

javascript - 在 Chrome 扩展程序中从 popup.html 连接到 background.js 脚本

html - 如何添加应该覆盖通用 css 的 google chrome 特定 css?

java - 在 Android 浏览器缓存中注入(inject)项目

html - 正在准备产品列表但 UI 不正确

javascript - 如何将 html 按钮链接到 asp.net 中的代码隐藏方法?

java - Vaadin 为网格中的选定行设置背景颜色

javascript - jQuery UI CSS 使 Firefox 与 Chrome 中的对话框内容不同