背景图案上方的 CSS 渐变

发布于 2024-11-05 00:52:43 字数 314 浏览 1 评论 0原文

我想制作图案背景和其上方的白到黑(具有透明度)渐变。如何解决它并使其跨浏览器工作?我从 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

苏佲洛 2024-11-12 00:52:43

您将需要两个独立的元素,一个元素覆盖另一个元素。顶部的元素听起来应该是你的渐变。另外仅供参考的是,这是一个用于生成跨浏览器渐变的出色工具,本周刚刚在 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/

少女七分熟 2024-11-12 00:52:43

试试这个:

    background-image: url(images/pattern.png),  -webkit-radial-gradient(0% 100%, rgb(20,150,254), rgb(119,117,174));
    background-image: url(images/pattern.png),  -moz-radial-gradient(0% 100%, rgb(20,150,254), rgb(119,117,174));
    background-image: url(images/pattern.png),  -ms-radial-gradient(0% 100%, rgb(20,150,254), rgb(119,117,174));
    background-image: url(images/pattern.png),  -o-radial-gradient(0% 100%, rgb(20,150,254), rgb(119,117,174));
    background-image: url(images/pattern.png),  radial-gradient(circle at 0% 100%, rgb(20,150,254), rgb(119,117,174));

Try this:

    background-image: url(images/pattern.png),  -webkit-radial-gradient(0% 100%, rgb(20,150,254), rgb(119,117,174));
    background-image: url(images/pattern.png),  -moz-radial-gradient(0% 100%, rgb(20,150,254), rgb(119,117,174));
    background-image: url(images/pattern.png),  -ms-radial-gradient(0% 100%, rgb(20,150,254), rgb(119,117,174));
    background-image: url(images/pattern.png),  -o-radial-gradient(0% 100%, rgb(20,150,254), rgb(119,117,174));
    background-image: url(images/pattern.png),  radial-gradient(circle at 0% 100%, rgb(20,150,254), rgb(119,117,174));
请帮我爱他 2024-11-12 00:52:43

我有一个适用于除 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 :/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文