目前,我有一个如下所示的垂直图像:
我需要的是图像只在顶部淡化,最终看起来像这样:
这是我开始的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;
}
请帮忙。
答案 0 :(得分:2)
您可以使用带有白色到透明渐变的<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%);
}
(我在这种特殊情况下使用了gradient generator)
检查出来:JSFiddle