Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
510 views
in Technique[技术] by (71.8m points)

CSS background-color not working in Safari

We can't get a CSS background colour to work in Safari.

It works in Chrome, Edge & Firefox. It should look like this:

enter image description here

Instead, the dark background colour is not showing at all, the background image for body is showing, which isn't what we want.

Here's a snippet:

.block-dark .block-overlay {
    background-color: #2d3133!important;
    position: absolute;    
    bottom: 0;
    left: 0;
    right: 0;
    top: 0;
    z-index: -1;
}
.block-dark .container {color: white;}
<div class="block-dark">
  <div class="block-overlay" style="opacity: 90%"></div>
  <div class="container">
    <div class="row">
      <div class="col-sm-12 col-xl-8">
        <h1>Air conditioning</h1>
      </div>
    </div>
  </div>
</div>
question from:https://stackoverflow.com/questions/66057597/css-background-color-not-working-in-safari

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Isn't that because of z-index: -1; ???

use this if you want to use z-index:

z-index: 0; // or 1

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...