如何添加z-index以从div边界分离图像

时间:2016-08-09 14:54:28

标签: html css

小提琴:https://jsfiddle.net/0qqnvrdg/

HTML:

Assert.That (resultEnumerable, Has.Some.Property ("Property").EqualTo ("x"));
Assert.That (resultEnumerable, Has.Some.Matches<X> (x => x.Property == "x"));

CSS:

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

如何将CSS修改为图像位于白色顶部的浅蓝色边框下。

这可能吗?

3 个答案:

答案 0 :(得分:2)

.loading {overflow: hidden} - 只需添加此行

即可

答案 1 :(得分:2)

添加了z-index:-1000; for under。

ps:滚动条的效果很好)

&#13;
&#13;
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;
}
&#13;
<div class="loading"></div>
&#13;
&#13;
&#13;

答案 2 :(得分:0)

这是因为您在div.loading之前添加背景图像,使图像成为内容。相反,将背景图像添加到div。