提问者:小点点

如何使用css制作叠加条纹渐变[重复]


如何在CSS中制作双渐变条纹集?类似于这样:

.stripe{
background:linear-gradient(
        45deg,
        rgba(255, 0, 0, 1) 0%,
        rgba(255, 154, 0, 1) 10%,
        rgba(208, 222, 33, 1) 21%,
        rgba(79, 220, 74, 1) 30%,
        rgba(63, 218, 216, 1) 40%,
        rgba(47, 201, 226, 1) 50%,
        rgba(28, 127, 238, 1) 60%,
        rgba(95, 21, 242, 1) 70%,
        rgba(186, 12, 248, 1) 80%,
        rgba(251, 7, 217, 1) 90%,
        rgba(255, 0, 0, 1) 100%
    );}
<div class = 'stripe'><h1>.</h1></div>

但覆盖程度相反:

.stripe{
background:linear-gradient(
        -45deg,
        rgba(255, 0, 0, 1) 0%,
        rgba(255, 154, 0, 1) 10%,
        rgba(208, 222, 33, 1) 21%,
        rgba(79, 220, 74, 1) 30%,
        rgba(63, 218, 216, 1) 40%,
        rgba(47, 201, 226, 1) 50%,
        rgba(28, 127, 238, 1) 60%,
        rgba(95, 21, 242, 1) 70%,
        rgba(186, 12, 248, 1) 80%,
        rgba(251, 7, 217, 1) 90%,
        rgba(255, 0, 0, 1) 100%
    );}
<div class = 'stripe'><h1>.</h1></div>
.stripe {
  background: repeating-linear-gradient(
      45deg,
    transparent,
    transparent 10px,
        rgba(255, 0, 0, 1) 10px,
        rgba(255, 154, 0, 1) 11px,
        rgba(208, 222, 33, 1) 12px,
        rgba(79, 220, 74, 1) 13px,
        rgba(63, 218, 216, 1) 14px,
        rgba(47, 201, 226, 1) 15px,
        rgba(28, 127, 238, 1) 16px,
        rgba(95, 21, 242, 1) 17px,
        rgba(186, 12, 248, 1) 18px,
        rgba(251, 7, 217, 1) 19px,
        rgba(255, 0, 0, 1) 20px
 
  ),
linear-gradient(
        45deg,
        rgba(255, 0, 0, 1) 0%,
        rgba(255, 154, 0, 1) 10%,
        rgba(208, 222, 33, 1) 20%,
        rgba(79, 220, 74, 1) 30%,
        rgba(63, 218, 216, 1) 40%,
        rgba(47, 201, 226, 1) 50%,
        rgba(28, 127, 238, 1) 60%,
        rgba(95, 21, 242, 1) 70%,
        rgba(186, 12, 248, 1) 80%,
        rgba(251, 7, 217, 1) 90%,
        rgba(255, 0, 0, 1) 100%
    );
}
<div class = 'stripe'><h1>.</h1></div>

但是这不起作用,因为它一遍又一遍地重复它。我如何让模式继续并在整个酒吧中传播?注意:如果不将度数更改为负数,它看起来是一样的,所以我希望叠加为-45。

我在问如何使叠加的一部分透明。我试图弄清楚如何制作两个渐变;将它们叠加成条纹图案。


共1个答案

匿名用户

相反的度数是测量超过180度的角度,如下所示:

.stripe{
    background-size:100% 100%; /*This fills the entire object with the
    gradient, without repetition*/
    background:linear-gradient(
        315deg, /*Instead of -45: 360 - 45 = 315 degrees*/
        rgba(255, 0, 0, 1) 0%,
        rgba(255, 154, 0, 1) 10%,
        rgba(208, 222, 33, 1) 21%,
        rgba(79, 220, 74, 1) 30%,
        rgba(63, 218, 216, 1) 40%,
        rgba(47, 201, 226, 1) 50%,
        rgba(28, 127, 238, 1) 60%,
        rgba(95, 21, 242, 1) 70%,
        rgba(186, 12, 248, 1) 80%,
        rgba(251, 7, 217, 1) 90%,
        rgba(255, 0, 0, 1) 100%);
}