Si8 Si8 - 3 months ago 18
CSS Question

How to add a z-index to separate image from div border

Fiddle: https://jsfiddle.net/0qqnvrdg/

HTML:

<div class="loading"></div>


CSS:

body {
background: #0d8aa5;
}

.loading {
position: absolute;
left: 50%;
top: 25%;
/*margin: -60px 0 0 -60px;*/
background: #fff;
width: 200px;
height: 200px;
border-radius: 100%;
border: 10px solid #19bee1;
}
.loading:after {
content: '';
background: trasparent;
width: 140%;
height: 140%;
position: absolute;
border-radius: 100%;
top: -20%;
left: -20%;
opacity: 0.7;
box-shadow: rgba(255, 255, 255, 0.6) -4px -5px 3px -3px;
animation: rotate 2s infinite linear;
}

@keyframes rotate {
0% {
transform: rotateZ(0deg);
}
100% {
transform: rotateZ(360deg);
}
}
.loading:before {
background-image: url('http://i.stack.imgur.com/UTnLP.png');
background-size: 100%;
background-repeat: no-repeat;
display: block;
width: 85%;
height: 85%;
content:"";
position: absolute;
top: 20%;
left: 10%;
}


How can I modify the CSS to that the image is under the thin blue border while being on top of the white.

Is that possible?

Answer

added z-index: -1000; for under.

ps: nice effect for scrollbar )

body {
  background: #0d8aa5;
}
.loading {
  position: absolute;
  left: 50%;
  top: 25%;
  /*margin: -60px 0 0 -60px;*/
  background: transparent;
  width: 200px;
  height: 200px;
  border-radius: 100%;
  border: 10px solid #19bee1;
}
.loading:after {
  content: '';
  background: trasparent;
  width: 140%;
  height: 140%;
  position: absolute;
  border-radius: 100%;
  top: -20%;
  left: -20%;
  opacity: 0.7;
  box-shadow: rgba(255, 255, 255, 0.6) -4px -5px 3px -3px;
  animation: rotate 2s infinite linear;
}
@keyframes rotate {
  0% {
    transform: rotateZ(0deg);
  }
  100% {
    transform: rotateZ(360deg);
  }
}
.loading:before {
  background-image: url('http://i.stack.imgur.com/UTnLP.png');
  background-size: cover;
  background-repeat: no-repeat;
  display: block;
  width: 100%;
  height: 100%;
  content: "";
  position: absolute;
  border-radius: 50%;
  z-index: -1000;
}
<div class="loading"></div>

Comments