[英]How do I create a gradient that goes form A to B to A in one direction and A to B in another direction?
I am looking to create a gradient that goes from A --> B --> A in the positive X direction while at the same time going from A --> B in the negative Y direction. 我正在寻找创建一个从A-> B-> A沿正X方向而同时从A-> B沿负Y方向而来的渐变。 Basically it should be one color on the left then fade to white and then back to the first color but should all fade to white at the bottom. 基本上,它应该是左侧的一种颜色,然后逐渐淡化为白色,然后又变回第一种颜色,但是底部的所有颜色都应该逐渐淡化为白色。 I have been trying to do this with CSS but I am not sure it is possible and am open to other option 我一直在尝试使用CSS进行此操作,但是我不确定是否有可能,并且愿意接受其他选择
You can layer 2 elements to achieve this ... jsfiddle https://jsfiddle.net/x0d5oLc4/ 您可以将第2层元素实现这一目标... jsfiddle https://jsfiddle.net/x0d5oLc4/
html html
<div id="bfcontainer">
<div id="bluefade"></div>
<div id="whitefade"></div>
</div>
css 的CSS
#bfcontainer {
position:relative;
}
#bluefade{
position:absolute;
z-index:1;
width:200px;
height:200px;
background: #1e5799; /* Old browsers */
background: -moz-linear-gradient(left, #1e5799 0%, #ffffff 49%, #1e5799 100%);
background: -webkit-linear-gradient(left, #1e5799 0%,#ffffff 49%,#1e5799 100%);
background: linear-gradient(to right, #1e5799 0%,#ffffff 49%,#1e5799 100%);
}
#whitefade{
display:block;
position:absolute;
z-index:2;
width:200px;
height:200px;
background: -moz-linear-gradient(top, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%);
background: -webkit-linear-gradient(top, rgba(255,255,255,0) 0%,rgba(255,255,255,1) 100%);
background: linear-gradient(to bottom, rgba(255,255,255,0) 0%,rgba(255,255,255,1) 100%);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.