线性和径向梯度定位

时间:2014-03-18 02:52:14

标签: html css css3 linear-gradients radial-gradients

做多个渐变是相当新的。我有一个线性渐变,然后是一个放射状的渐变。

background-image: -webkit-gradient(
    linear,
    left bottom,
    left top,
    color-stop(0, #033968),
    color-stop(1, #408BCD)
);
background-image: url('../img/background-noise.png'), -o-linear-gradient(top, #033968 0%, #408BCD 100%);
background-image: url('../img/background-noise.png'), -ms-linear-gradient(top, #033968 0%, #408BCD 100%);
background-image: url('../img/background-noise.png'), -moz-radial-gradient(center top, farthest-side, rgba(255,255,255,1) 0, rgba(255,255,255,0) 100px), -moz-linear-gradient(top, #033968 0%, #408BCD 100%);
background-image: url('../img/background-noise.png'), -webkit-radial-gradient(center top, farthest-side, rgba(255,255,255,1) 0, rgba(255,255,255,0) 100px), -webkit-linear-gradient(top, #033968 0%, #408BCD 100%);
background-image: url('../img/background-noise.png'), radial-gradient(farthest-side at center top, rgba(255,255,255,1) 0, rgba(255,255,255,0) 100px), linear-gradient(to top, #033968 0%, #408BCD 100%);

它工作正常,但我想知道为什么径向渐变的大小是以像素为单位定义的,但它的行为就像一个%。

退房:http://jsfiddle.net/tK5Ch/

调整浏览器大小时,径向渐变会移动。我只想修复它,比如100px x 100px

任何想法发生了什么?

1 个答案:

答案 0 :(得分:1)

Since you have two separate axes defined, the default shape is ellipse。您需要指定它是circle

http://jsfiddle.net/tK5Ch/3/(仅更改了标准渐变)

radial-gradient(circle farthest-side at center top, ...
相关问题