CSS3 跨浏览器渐变背景与 rgb/rgba 和后备
我想尝试使用 rgb
值获得跨浏览器渐变效果,并在浏览器不支持的情况下进行回退。
jsFiddle 示例: http://jsfiddle.net/HelloJoe/hUxdh/
我相信我已经介绍了大多数浏览器,但我有几个问题:
是否有我错过的其他常用浏览器,以及 iPad/智能手机等设备需要哪些属性,或者它们会从当前使用的属性之一渲染?
如果偶然未渲染渐变,则原始
背景:rgb(50, 50, 50);
是否足以生成纯色?使用
filter
值时,我无法通过使用rgb
值来使其工作,而不得不求助于使用hex
值,并不是说这是一个大问题,但我尝试只使用rgb
值。有没有办法解决这个问题,或者它只是不接受它们?如果我要使用
rgba
而不是rgb
,那么我需要有一个rgba
渐变背景值,一个rgb
渐变背景值作为不渲染 alpha 透明度的后备,然后在根本没有渲染渐变的情况下使用纯色背景后备?或者浏览器会忽略 alpha 透明度值并仅显示rgba
中的rgb
而无需单独的rgb
背景回退吗?作为所有事情的最后后备方案,是否需要在 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:
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?
If by chance the gradient isn't rendered, is having the original
background: rgb(50, 50, 50);
enough to generate just a solid colour?With the
filter
value, I couldn't get it working by usingrgb
values and had to resort to using ahex
value instead, not that this is a huge problem, but I'm trying to only usergb
values. Is there a way round this or does it just not accept them?If I was to use
rgba
instead ofrgb
would I then need to have argba
gradient background value, anrgb
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 thergb
from thergba
without a separatergb
background fall back?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 ahex
value but the idea of usingrgb
is ifrgba
is usable it makes for a quick and easy colour change throughout the site. So having a fall backhex
value would make usingrgb/rgba
pointless for what I'm intending it's used for since I'd need to go through and edit allhex
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我可以向您推荐这个网站来帮助您处理渐变和后备:
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/