我只是想知道是否有人知道是否可以使用 css 使图像的边缘透明?我知道它可以对背景图像完成,并且我已经在我的网站上使用了这种方法。我希望做的是使幻灯片中包含的图像的侧面和底部透明,以便它们淡入背景。我真的不想在Photoshop中单独制作每个图像,并希望找到一种使用css甚至JavaScript的可靠方法。感谢您的时间和帮助。
是的...您可以这样做:
.mask {
background: -moz-linear-gradient(top, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(255,255,255,0)), color-stop(100%,rgba(255,255,255,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(255,255,255,0) 0%,rgba(255,255,255,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(255,255,255,0) 0%,rgba(255,255,255,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(255,255,255,0) 0%,rgba(255,255,255,1) 100%); /* IE10+ */
background: linear-gradient(to bottom, rgba(255,255,255,0) 0%,rgba(255,255,255,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00ffffff', endColorstr='#ffffff',GradientType=0 ); /* IE6-9 */
z-index: 2;
position: absolute;
left: 0;
width: 100%;
bottom: 0;
height: 50%;
}
.fader {display: inline-block;}
.fader img {position: relative; z-index: 1;}
<div class="fader">
<img src="http://lorempixel.com/400/200/animals/" />
<div class="mask"></div>
</div>