Background color CSS not working in safari but wor

2019-09-08 14:40发布

I have made a website in which i am applying white background color(#FFF ) to my panels(a div) to add some transparency effect. This works very fine in chrome & firefox . But doesn't work in Safari. What should i do to create the same effect in safari.

.panel{
    position:relative;
    background-color: #FFF;
    background:#FFF;
    bgcolor:#FFF;
    #safari { background-color:#FFF }
}

I have tried all versions of background color(bgcolor, background-color etc) & also tried the hack

#safari{
    background-color:#FFF
} 

but none worked. please help. Also the Link tags not working in IE only but working perfectly in other browsers.

3条回答
不美不萌又怎样
2楼-- · 2019-09-08 15:29

This blog post suggests this CSS hack:

# @media screen and (-webkit-min-device-pixel-ratio:0) {
    #safari { background-color:#FFF }
}
查看更多
叼着烟拽天下
3楼-- · 2019-09-08 15:35

try this:

   _::-webkit-full-page-media, _:future, :root .panel {
     background-color:#FFF
  }

Edited: this works for safari 7.1+ (in your case, 8.0)

查看更多
再贱就再见
4楼-- · 2019-09-08 15:40

A white background does not add any transparency.

You can try the following, which should work in all browsers:

.my-class {
    background-color: rgb(255,255,255); // White background for old browsers
    background-color: rgba(255,255,255,0.5); // White background, 50% transparency for more modern browsers. Will be ignored by old browsers
}
查看更多
登录 后发表回答