背景图案上方的 CSS 渐变
我想制作图案背景和其上方的白到黑(具有透明度)渐变。如何解决它并使其跨浏览器工作?我从 Mozilla 开始,尝试使用下面的代码:
background: url(../images/bg_pattern.gif), -moz-linear-gradient( rgba(255, 255, 255, 0.5) 5%, rgba(130, 130, 130, 0.5) 95%
当然,这是行不通的。那么如何解决呢?该代码在其他浏览器中会是什么样子? IE支持多种背景和透明度吗?我认为不是,所以在你回答之前我会问 - 如何为 IE 解决这个问题?
I want to make pattern background and a white to black (with transparency) gradient above it. How to work it out and also make it work cross-browser? I'm starting with Mozilla and I've tried to use code below:
background: url(../images/bg_pattern.gif), -moz-linear-gradient( rgba(255, 255, 255, 0.5) 5%, rgba(130, 130, 130, 0.5) 95%
Of course this does not work. So how to work it out? How would the code look for other browsers? Does IE support many backgrounds and transparency? I think it doesn't so I'll ask before your answers - how to work it out for IE?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您将需要两个独立的元素,一个元素覆盖另一个元素。顶部的元素听起来应该是你的渐变。另外仅供参考的是,这是一个用于生成跨浏览器渐变的出色工具,本周刚刚在 An Event Apart 上推出:
http ://www.colorzilla.com/gradient-editor/
You will need two separate elements, one overlaying the other. The element on top sounds like it should be your gradient. Also FYI here is a great tool for generating cross-browser gradients, just launched this week at An Event Apart:
http://www.colorzilla.com/gradient-editor/
试试这个:
Try this:
我有一个适用于除 IE 之外的所有内容的工作版本。 :/我不记得在哪里找到它,所以我不能给予适当的信任;然而,这里是:
背景:-webkit-线性渐变(rgba(224,147,43,.9),rgba(224,147,43,.8))固定,#454040 url(images/grainy2.png)重复固定;
背景:-ms-linear-gradient(rgba(224,147,43,.9), rgba(224,147,43,.95)) 固定,#454040 url(images/grainy2.png) 重复固定;
背景:-o-linear-gradient(rgba(224,147,43,.9), rgba(224,147,43,.95)) 固定,#454040 url(images/grainy2.png) 重复固定;
背景:-moz-linear-gradient(rgba(224,147,43,.9), rgba(224,147,43,.95)) 固定,#454040 url(images/grainy2.png) 重复固定;
第一种颜色是你的上衣,第二种是你的下装,第三种是图案上的颜色(不知道如何将其减少为透明)。最后直接进入你的模式。
我不完全确定 ms 的用途。就像我说的,我已经使用它大约几个月了,但我不记得来源了。我只是使用它们来确保它们有效。 IE 仍然没有修复:/
I have a working version for everything excepting IE. :/ I don't remember where I found it, so I can not give the proper credit; however, here it is:
background: -webkit-linear-gradient(rgba(224,147,43,.9), rgba(224,147,43,.8)) fixed, #454040 url(images/grainy2.png) repeat fixed;
background: -ms-linear-gradient(rgba(224,147,43,.9), rgba(224,147,43,.95)) fixed, #454040 url(images/grainy2.png) repeat fixed;
background: -o-linear-gradient(rgba(224,147,43,.9), rgba(224,147,43,.95)) fixed, #454040 url(images/grainy2.png) repeat fixed;
background: -moz-linear-gradient(rgba(224,147,43,.9), rgba(224,147,43,.95)) fixed, #454040 url(images/grainy2.png) repeat fixed;
The first color is your top, the second your bottom, and the third is the color over the pattern (not sure how you would reduce that to transparent). Finally just direct to your pattern.
I'm not entirely sure what ms is for. Like I said, I've been using it for about a few months, but I do not remember the source. I just use them all to make sure they work. Still no fix to IE :/