简体   繁体   English

透明背景颜色不在移动设备上工作

[英]Transparent background color not working on mobile devices

On desktop we have a transparent header and footer working fine, you can see the background image: https://www.ontarioslakecountry.com/ 在桌面上我们有一个透明的页眉和页脚工作正常,你可以看到背景图像: https//www.ontarioslakecountry.com/

However, once we go into mobile on a iOS or Android device, it shows as solid and not transparent. 但是,一旦我们在iOS或Android设备上进入移动设备,它就会显示为稳固且不透明。

 .site-header { background-color: rgba(0, 84, 166, 0.5); background: rgba(0, 84, 166, 0.5); color: rgba(0, 84, 166, 0.5); } 

RGBA has somewhat limited support on mobile browsers: https://caniuse.com/#search=rgba RGBA对移动浏览器的支持有限: https//caniuse.com/#search=rgba

There are some techniques for providing fallbacks to browsers that cannot deal with the rgba values. 有一些技术可以为浏览器提供无法处理rgba值的回退。 I noticed in your site header, you have css background-color and background properties both using the same value. 我注意到在你的网站标题中,你有css background-colorbackground属性都使用相同的值。

One approach is to use two different background rules with the first one set the value to a rgb value that non-supporting browsers will use as a fallback: 一种方法是使用两个不同的background规则,第一个将值设置为rgb值,非支持的浏览器将用作后备:

background: rgb(0, 84, 166); /* fallback color */
background: rgba(0, 84, 166, 0.5);

There are other approaches that use filters to try and maintain the transparency on non-supporting browsers. 还有其他方法使用过滤器来尝试和维护不支持的浏览器的透明度。 Here is a good article that goes into more depth: https://css-tricks.com/rgba-browser-support/ 这是一篇更深入的文章: https//css-tricks.com/rgba-browser-support/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM