【问题标题】:linear and radial gradient positioning线性和径向梯度定位
【发布时间】:2014-04-23 13:14:23
【问题描述】:

做多个渐变是相当新的。我有一个线性渐变,然后是顶部的径向渐变。

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

有什么想法吗?

【问题讨论】:

    标签: html css linear-gradients radial-gradients


    【解决方案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, ...
    

    【讨论】:

    • 太棒了。好,易于。谢谢!
    猜你喜欢
    • 2020-01-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-16
    • 2017-12-03
    • 2012-12-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多