条纹渐变背景

时间:2020-04-18 06:29:37

标签: css

我希望在渐变背景上有条纹。请参见下图的条纹图案。我的渐变背景如下:

 background-image: linear-gradient(90deg, hsla(209, 33%, 82%, 1), rgb(240,240,240), hsla(37, 33%, 85%, 1));

Stripes

如果您观察图像的底部,则不会发现条纹和渐变感。条纹应仅在背景的上方。

3 个答案:

答案 0 :(得分:1)

在div上设置渐变

在伪图像上设置条纹

为此伪设置一个遮罩,从不透明变为透明

.test {
  background-image: linear-gradient(90deg, hsla(209, 33%, 82%, 1), rgb(240,240,240), hsla(37, 33%, 85%, 1));
  width: 100%;
  height: 400px;
  position: relative;
}

.test:after {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    -webkit-mask-image: linear-gradient(rgba(0, 0, 0, 1.0) 10%, transparent 80%);
            mask-image: linear-gradient(rgba(0, 0, 0, 1.0) 10%, transparent 80%);
    background-image: repeating-linear-gradient(45deg, white 0px, white 10px, lightblue 10px, lightblue 20px);
}
<div class="test"></div>

答案 1 :(得分:0)

根据颜色组合,这是我可以实现的,我想这可能会帮助您入门:

您必须将角度更改为45度。

希望这对您有所帮助

.stripe {
  width: 800px;
  height: 900px;
  background-image: linear-gradient(to top, #dadee0 20px, rgba(125, 168, 196, 0.5)), repeating-linear-gradient(45deg, hsla(209, 33%, 82%, 1), rgb(240, 240, 240) 100px, hsla(37, 33%, 85%, 1) 50px);
}
<h2 class="stripe"></h2>

.stripe {
  width: 500px;
  height: 700px;
  background-image: repeating-linear-gradient(45deg, hsla(209, 33%, 82%, 1), rgb(240, 240, 240) 100px, hsla(37, 33%, 85%, 1) 100px);
}
<h2 class="stripe"></h2>

类似这样的东西:

.stripe {
  width: 50%;
  height: 700px;
  margin: 50 auto;
  background: repeating-linear-gradient( 45deg, #83ABC6 0px, #83ABC6 50px, #9BBBCF 50px, #9BBBCF 100px);
}
<h2 class="stripe"></h2>

答案 2 :(得分:-1)

享受

<!DOCTYPE html>
<html>
<head>
<style>
div {
    width: 500px;
    height: 500px;
    background-image: repeating-linear-gradient(
      45deg,
      transparent,
      transparent 50px,
      rgba(0, 0, 0, 0.1) 50px,
      rgba(0, 0, 0, 0.1) 100px
    ),
    linear-gradient(
      0deg,
      #c8d5e2,
      #7da9c4
    );
}
</style>
</head>
<body>

<div>
    content
</div>

</body>
</html>

现在尝试此代码[编辑]

<!DOCTYPE html>
<html>
<head>
<style>
div {
    width: 250px;
    height: 600px;
    background-image: linear-gradient(
      0deg,
      #dadee0,
      rgba(126, 169, 196, 0.5)
    ), repeating-linear-gradient(
      45deg,
      transparent,
      transparent 50px,
      rgba(0, 0, 0, 0.05) 50px,
      rgba(0, 0, 0, 0.05) 100px
    );
}
</style>
</head>
<body>

<div>
    content
</div>

</body>
</html>

获取最新图片[编辑]

<!DOCTYPE html>
<html>
<head>
<style>
div {
    width: 600px;
    height: 400px;
    background-image: linear-gradient(
      0deg,
      #dadee0 200px,
      rgba(126, 169, 196, 0.5)
    ), repeating-linear-gradient(
      45deg,
      transparent,
      transparent 10px,
      rgba(0, 0, 0, 0.05) 10px,
      rgba(0, 0, 0, 0.05) 20px
    );
}
</style>
</head>
<body>

<div>
</div>

</body>
</html>