【问题标题】:Css multiple gradientCSS多重渐变
【发布时间】:2014-09-08 11:21:27
【问题描述】:

我想在 CSS 中设置一个元素的背景样式,如下所示:

  • 颜色从上到下渐变,没有任何透明度,
  • 从左到右的单色透明渐变:左右不透明,中间100%透明
  • 第二个渐变应该在比第一个更高的层上。两者都放置在元素区域的 100% 上

代码:

div.panel div.panel-heading
{
    background: linear-gradient(to bottom, #e8e8e8 0%,#dbdbdb 50%,#cdcdcd 51%,#e0e0e0 100%),
    /* Here I want have got second gradient, with transparency, on higher layer */;
}

这可能吗?

【问题讨论】:

标签: css gradient


【解决方案1】:

:after 和 :before 是可能的:

.gradient{
    height:400px;
    background: #61fc32;
    background: -moz-linear-gradient(left, #61fc32 0%, #f43034 100%);
    background: -webkit-gradient(linear, left top, right top, color-stop(0%,#61fc32), color-stop(100%,#f43034));
    background: -webkit-linear-gradient(left, #61fc32 0%,#f43034 100%);
    background: -o-linear-gradient(left, #61fc32 0%,#f43034 100%);
    background: -ms-linear-gradient(left, #61fc32 0%,#f43034 100%);
    background: linear-gradient(to right, #61fc32 0%,#f43034 100%);
    position:relative;
}
.gradient:after{
    content:'';
    position:absolute;
    top:0;
    left:0;
    width:100%;
    height:100%;
    background: -moz-radial-gradient(center, ellipse cover, rgba(40,51,201,0) 0%, rgba(40,51,201,1) 100%);
    background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%,rgba(40,51,201,0)), color-stop(100%,rgba(40,51,201,1)));
    background: -webkit-radial-gradient(center, ellipse cover, rgba(40,51,201,0) 0%,rgba(40,51,201,1) 100%);
    background: -o-radial-gradient(center, ellipse cover, rgba(40,51,201,0) 0%,rgba(40,51,201,1) 100%);
    background: -ms-radial-gradient(center, ellipse cover, rgba(40,51,201,0) 0%,rgba(40,51,201,1) 100%);
    background: radial-gradient(ellipse at center, rgba(40,51,201,0) 0%,rgba(40,51,201,1) 100%);
}

DEMO

【讨论】:

    猜你喜欢
    • 2015-04-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多