可以使用CSS来使背景图像“褪色”或渐变底部透明,使背景颜色显示? [英] Is it possible to use css to make a background image "fade" or gradient the bottom portion to transparent so that a background color shows?
本文介绍了可以使用CSS来使背景图像“褪色”或渐变底部透明,使背景颜色显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道这可以很容易地在任何图像编辑程序,我只是好奇,如果有一个方法只是使用css。
I know that this can easily be done in any image editing program, I was just curious if there was a way just using css.
示例:
body {background-color: #837960; background-image: url("Images/background.jpg") background-repeat: no-repeat;}
推荐答案
可以在CSS3中为背景设置多个值。
It is possible - in CSS3 you can set multiple values for background
body {
background: #837960 url("Images/background.jpg") 0 0 no-repeat;
background: -moz-linear-gradient(top, rgba(255,255,255,0) 0%, rgba(130,91,0,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(255,255,255,0)), color-stop(100%,rgba(130,91,0,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(255,255,255,0) 0%,rgba(130,91,0,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(255,255,255,0) 0%,rgba(130,91,0,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(255,255,255,0) 0%,rgba(130,91,0,1) 100%); /* IE10+ */
background: linear-gradient(to bottom, rgba(255,255,255,0) 0%,rgba(130,91,0,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00ffffff', endColorstr='#825b00',GradientType=0 ); /* IE6-9 */
}
但是,支持CSS3
(通过 http://www.colorzilla生成的代码.com / gradient-editor / )
这篇关于可以使用CSS来使背景图像“褪色”或渐变底部透明,使背景颜色显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文