0

目前,我有一个看起来像这样的垂直图像:

在此处输入图像描述

我需要的是让图像仅在顶部褪色,使其最终看起来像这样:

在此处输入图像描述

这是我开始的 JSFiddle:http: //jsfiddle.net/R6KSM/

我设置的 CSS 很简单:

.line {
  height: 500px;
  margin-left: 200px;
  background: url('http://i.imgur.com/UEfCV17.png') repeat-y;
}

.line > .content {
  padding: 20px;
}

请帮忙。

4

1 回答 1

2

您可以将 a<div>与白色到透明的渐变一起使用:

HTML

<div class="line">
    <div class="fadeTop"></div>
    <div class="content">
        This is just a sample paragraph.
    </div>
</div>

CSS

.fadeTop{
    height:20px;width:100%;position:absolute;left:0; top:0;
    background: -moz-linear-gradient(top,  rgba(255,255,255,1) 0%, rgba(255,255,255,0) 100%);
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(255,255,255,1)), color-stop(100%,rgba(255,255,255,0)));
    background: -webkit-linear-gradient(top,  rgba(255,255,255,1) 0%,rgba(255,255,255,0) 100%);
    background: -ms-linear-gradient(top,  rgba(255,255,255,1) 0%,rgba(255,255,255,0) 100%);
    background: linear-gradient(to bottom,  rgba(255,255,255,1) 0%,rgba(255,255,255,0) 100%);
}

(我在这种特殊情况下使用了梯度生成器)

看看:JSFiddle

于 2013-07-17T09:24:14.787 回答