CSS3 跨浏览器渐变背景与 rgb/rgba 和后备

发布于 2024-12-04 01:59:32 字数 1146 浏览 1 评论 0原文

我想尝试使用 rgb 值获得跨浏览器渐变效果,并在浏览器不支持的情况下进行回退。

jsFiddle 示例: http://jsfiddle.net/HelloJoe/hUxdh/

我相信我已经介绍了大多数浏览器,但我有几个问题:

  1. 是否有我错过的其他常用浏览器,以及 iPad/智能手机等设备需要哪些属性,或者它们会从当前使用的属性之一渲染?

  2. 如果偶然未渲染渐变,则原始背景:rgb(50, 50, 50);是否足以生成纯色?

  3. 使用 filter 值时,我无法通过使用 rgb 值来使其工作,而不得不求助于使用 hex 值,并不是说这是一个大问题,但我尝试只使用 rgb 值。有没有办法解决这个问题,或者它只是不接受它们?

  4. 如果我要使用 rgba 而不是 rgb,那么我需要有一个 rgba 渐变背景值,一个 rgb 渐变背景值作为不渲染 alpha 透明度的后备,然后在根本没有渲染渐变的情况下使用纯色背景后备?或者浏览器会忽略 alpha 透明度值并仅显示 rgba 中的 rgb 而无需单独的 rgb 背景回退吗?

  5. 作为所有事情的最后后备方案,是否需要在 CSS 属性的开头设置一个 hex 值?我想添加一个 hex 值没有什么坏处,但是使用 rgb 的想法是,如果 rgba 可用,那么它可以快速而简单地实现整个网站的颜色发生变化。因此,拥有一个后退的hex值将使使用rgb/rgba对于我想要的用途来说毫无意义,因为我需要遍历并编辑所有无论如何,>hex 值。

我做了一些搜索,示例各不相同,不同的人之间的理解被误解,我只是尝试创建一个准确的工作示例来获得所需的结果。

I want to try and get a cross browser gradient effect working with rgb values with fall backs in case the browser doesn't support it.

jsFiddle example: http://jsfiddle.net/HelloJoe/hUxdh/

I believe I've covered the majority of browsers, but I have a few questions:

  1. Are there any other browsers that I have missed which are commonly used, as well as what properties would be needed for devices such as iPads/SmartPhones, or would they render from one of the currently used properties?

  2. If by chance the gradient isn't rendered, is having the original background: rgb(50, 50, 50); enough to generate just a solid colour?

  3. With the filter value, I couldn't get it working by using rgb values and had to resort to using a hex value instead, not that this is a huge problem, but I'm trying to only use rgb values. Is there a way round this or does it just not accept them?

  4. If I was to use rgba instead of rgb would I then need to have a rgba gradient background value, an rgb gradient background value as a fall back for not rendering the alpha transparency and then a solid background fall back in case no gradient was rendered at all? Or would the browser ignore the alpha transparency value and just display the rgb from the rgba without a separate rgb background fall back?

  5. As a final fall back for everything, would having a set hex value at the start of the CSS properties be needed? I guess there is no harm is adding a hex value but the idea of using rgb is if rgba is usable it makes for a quick and easy colour change throughout the site. So having a fall back hex value would make using rgb/rgba pointless for what I'm intending it's used for since I'd need to go through and edit all hex values anyway.

I've done a bit of searching and examples vary, understanding is misinterpreted between different people and I was just try to create an accurate working example of getting the desired outcome.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

许久 2024-12-11 01:59:32

我可以向您推荐这个网站来帮助您处理渐变和后备:
http://www.colorzilla.com/gradient-editor/

May i suggest you this website to help you with your Gradients and fallback:
http://www.colorzilla.com/gradient-editor/

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