有人可以解释下面的径向渐变语法,并且可能提供适用于现代浏览器的CSS3标准格式的等效语法吗?
-webkit-radial-gradient( 50% 50%, 200% 50%, hsla(0, 0%, 90%, 1) 5%, hsla(0, 0%, 85%, 1) 30%, hsla(0, 0%, 60%, 1) 100%)
答案 0 :(得分:4)
-webkit-radial-gradient(50% 50%,
200% 50%,
hsla(0, 0%, 90%, 1) 5%, hsla(0, 0%, 85%, 1) 30%, hsla(0, 0%, 60%, 1) 100%)
上面提供的radial-gradient
可以解释如下:
50% 50%
定义了渐变图像的中心点的位置。这里只是应用它的容器元素的中心。200% 50%
定义X轴和Y轴的渐变半径。这里半径是容器在X轴上的宽度的200%和容器在Y轴上的高度的50%。hsla(0, 0%, 90%, 1)
,直到5%,从5%到30%,颜色会逐渐从hsla(0, 0%, 90%, 1)
移动到hsla(0, 0%, 85%, 1)
,然后从30%增加到100%,它会从hsla(0, 0%, 85%, 1)
至hsla(0, 0%, 60%, 1)
。此radial-gradient
的等效标准语法如下:
background: radial-gradient(ellipse 200% 50% at 50% 50%, hsla(0, 0%, 90%, 1) 5%, hsla(0, 0%, 85%, 1) 30%, hsla(0, 0%, 60%, 1) 100%);
下面的代码段有两个输出用于比较。
div {
float: left;
height: 250px;
width: 250px;
border: 1px solid black;
margin-right: 4px;
}
.radial-grad {
background: -webkit-radial-gradient(50% 50%, 200% 50%, hsla(0, 0%, 90%, 1) 5%, hsla(0, 0%, 85%, 1) 30%, hsla(0, 0%, 60%, 1) 100%);
}
.radial-grad-standard {
background: radial-gradient(ellipse 200% 50% at 50% 50%, hsla(0, 0%, 90%, 1) 5%, hsla(0, 0%, 85%, 1) 30%, hsla(0, 0%, 60%, 1) 100%);
}

<div class='radial-grad'></div>
<div class='radial-grad-standard'></div>
&#13;