[英]Creating a linear gradient with an angle
您需要考虑多个背景:
.box { height:200px; background: linear-gradient(to bottom right,#fff 49%,transparent 50%) top/100% 30%, linear-gradient(to right, #007bff, #0C4078); background-repeat:no-repeat; }
<div class="box"></div>
如果您想要透明度,您可以使用带有一个背景的clip-path
:
.box { height:200px; background:linear-gradient(to right, #007bff, #0C4078); -webkit-clip-path:polygon(0 30%,0 100%, 100% 100%,100% 0); clip-path:polygon(0 30%,0 100%, 100% 100%,100% 0); }
<div class="box"></div>
或者mask
.box { height:200px; background: linear-gradient(to right, #007bff, #0C4078); -webkit-mask: linear-gradient(to bottom right,transparent 49%,white 50%) top/100% 30% no-repeat, linear-gradient(white,white) bottom/100% 70% no-repeat; mask: linear-gradient(to bottom right,transparent 49%,white 50%) top/100% 30% no-repeat, linear-gradient(white,white) bottom/100% 70% no-repeat; }
<div class="box"></div>
如果您想要透明度和比clip-path
/ mask
更好的支持,这是另一种方法:
.box { height: 200px; position: relative; overflow: hidden; z-index: 0; } .box:before { content: ""; position: absolute; z-index: -1; top: 0; left: 0; right: 0; bottom: 0; transform: skewY(-5deg); transform-origin: right; background: linear-gradient(to right, #007bff, #0C4078); }
<div class="box"></div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.