2

我想用 CSS 来做。我不希望整个图像在每个像素上都具有相同的透明度。

4

2 回答 2

2

您可以使用 CSS3 Mask 属性。一篇很好的文章:http ://css-tricks.com/webkit-image-wipes/

于 2012-08-11T15:08:48.153 回答
1

可以办到!

/* using the mozilla kit */
background-image: -moz-linear-gradient(
  rgba(255, 255, 255, 0.7) 0%, rgba(255, 255, 255, 0) 95%
);

/* using webkit */
background-image: -webkit-gradient(
  linear, left top, left bottom, from(rgba(50,50,50,0.8)),
  to(rgba(80,80,80,0.2)), color-stop(.5,#333333)
);

这些应该适用于所有浏览器:http: //www.leon-zinger.com/css-tricks/css3-gradients-with-opacity-works-with-iehttp://lea.verou.me/2009/02 /bulletproof-cross-browser-rgba-backgrounds/

于 2012-08-11T15:04:36.100 回答