另一个线性渐变内的线性渐变
Linear gradient inside another linear gradient
我正在尝试在另一个线性渐变中创建一个线性渐变,这可能吗?下面的例子
background: linear-gradient(to right, #color1 50%, #color2 0%)
颜色 1 是
background: linear-gradient(#aa0507,#e0171e,#aa0507);
颜色 2 是
background: linear-gradient(#f4c05b,#fcd580,#f4c05b);
最终结果应该是这样
只需调整 background-position
/background-size
使用多重背景。基本上每个渐变都是半宽全高。
body {
margin:0;
height:100vh;
background:
linear-gradient(#aa0507,#e0171e,#aa0507) right/50% 100%,
linear-gradient(#f4c05b,#fcd580,#f4c05b) left /52% 100%; /*we can make this a little bigger to avoid the blank space*/
background-repeat:no-repeat;
}
你可以将两个渐变组合成background: linear-gradient(to right, #f4c05b, #fcd580, #f4c05b 50%, #aa0507 50%, #e0171e, #aa0507)
来得到效果——注意左右两部分的渐变都是left在这个答案中向右 。
参见下面的演示:
body {
background: linear-gradient(to right, #f4c05b, #fcd580, #f4c05b 50%, #aa0507 50%, #e0171e, #aa0507);
}
我正在尝试在另一个线性渐变中创建一个线性渐变,这可能吗?下面的例子
background: linear-gradient(to right, #color1 50%, #color2 0%)
颜色 1 是
background: linear-gradient(#aa0507,#e0171e,#aa0507);
颜色 2 是
background: linear-gradient(#f4c05b,#fcd580,#f4c05b);
最终结果应该是这样
只需调整 background-position
/background-size
使用多重背景。基本上每个渐变都是半宽全高。
body {
margin:0;
height:100vh;
background:
linear-gradient(#aa0507,#e0171e,#aa0507) right/50% 100%,
linear-gradient(#f4c05b,#fcd580,#f4c05b) left /52% 100%; /*we can make this a little bigger to avoid the blank space*/
background-repeat:no-repeat;
}
你可以将两个渐变组合成background: linear-gradient(to right, #f4c05b, #fcd580, #f4c05b 50%, #aa0507 50%, #e0171e, #aa0507)
来得到效果——注意左右两部分的渐变都是left在这个答案中向右 。
参见下面的演示:
body {
background: linear-gradient(to right, #f4c05b, #fcd580, #f4c05b 50%, #aa0507 50%, #e0171e, #aa0507);
}