具有透明背景的微调器?

时间:2017-03-29 07:50:45

标签: html css css3 css-animations

我有一个带有白色背景的微调器,通过关键帧进行动画处理。那么,有了这个代码笔,如何在不影响原始设计的情况下将这种颜色移除到“smt-spinner-inner-circle”类?如果删除背景,则该部分可见。我试图应用剪辑,但结果不是预期的。

http://codepen.io/anon/pen/WpagJN

HTML:

<div class="smt-spinner-circle">
   <div class="smt-spinner"></div>
   <div class="smt-spinner-inner-circle"></div>
</div>

总而言之,我需要旋转器的背景透明而不是红色,因为根据您的页面(灰色,白色等),网站将是不同的背景......

4 个答案:

答案 0 :(得分:6)

为什么不这样做,这将在任何背景,包括图像

之上透明

.test {
  display: inline-block;
  padding: 20px;
}
.test.red{
  background: red;
}
.test.green{
  background: green;
}
.test.image{
  background: url(http://lorempixel.com/500/200/nature/1/);
}

.smt-spinner-circle {
  width: 50px;
  height: 50px;
  position: relative;
  margin: 20px;
  border-radius: 50%;
}
.smt-spinner {
  height: 100%;
  width: 100%;
  border-radius: 50%;
  border-right: 2px solid rgba(255,255,255,0.6);
  border-top: 2px solid blue;
  border-left: 2px solid blue;
  border-bottom: 2px solid blue;
  animation: rotate--spinner 1.6s infinite;
}

@keyframes rotate--spinner {
  from {
    transform: rotate(0);
  }
  to {
    transform: rotate(360deg);
  }
}
<div class="test red">
  <div class="smt-spinner-circle">
   <div class="smt-spinner"></div>
  </div>
</div>
<div class="test green">
  <div class="smt-spinner-circle">
   <div class="smt-spinner"></div>
  </div>
</div>
<div class="test image">
  <div class="smt-spinner-circle">
   <div class="smt-spinner"></div>
  </div>
</div>

答案 1 :(得分:3)

您的background-color隐藏了旋转的三角形,因此只需更改background: white即可匹配您的背景颜色。

&#13;
&#13;
body{
  background: red;
}
.smt-spinner-circle {
  width: 50px;
  height: 50px;
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  margin: auto;
  background: blue;
  border-radius: 50%;
}

.smt-spinner-inner-circle {
  width: 92%;
  height: 92%;
  background: red;
  border-radius: 50%;
  margin: auto;
  vertical-align: middle;
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
}

.smt-spinner {
  height: 0;
  width: 0;
  border-radius: 50%;
  border-right: 25px solid rgba(255,255,255,0.6);
  border-top: 25px solid transparent;
  border-left: 25px solid transparent;
  border-bottom: 25px solid transparent;
  animation: rotate--spinner 1.6s infinite;
}

@keyframes rotate--spinner {
  from {
    transform: rotate(0);
  }
  to {
    transform: rotate(360deg);
  }
}
&#13;
<div class="smt-spinner-circle">
   <div class="smt-spinner"></div>
   <div class="smt-spinner-inner-circle"></div>
</div>
&#13;
&#13;
&#13;

答案 2 :(得分:1)

您可以创建一个只有一个元素和不同边框样式的简单微调器。

.loader{
    border: 2px solid #CECECE; 
    border-top-color: #14B48C; 
    width: 40px; 
    height: 40px; 
    border-radius: 50%; 
    animation: spin 1s infinite;
}

@keyframes spin{
    from{transform: rotate(0deg);}
    to{transform: rotate(360deg);}
}

答案 3 :(得分:0)

CSS 代码

@keyframes ldio-rpinwye8j0b {
  0% { transform: rotate(0deg) }
  50% { transform: rotate(180deg) }
  100% { transform: rotate(360deg) }
}
.ldio-rpinwye8j0b div {
  position: absolute;
  animation: ldio-rpinwye8j0b 1s linear infinite;
  width: 160px;
  height: 160px;
  top: 20px;
  left: 20px;
  border-radius: 50%;
  box-shadow: 0 4px 0 0 #e15b64;
  transform-origin: 80px 82px;
}
.loadingio-eclipse {
  width: 200px;
  height: 200px;
  display: inline-block;
  overflow: hidden;
}
.ldio-rpinwye8j0b {
  width: 100%;
  height: 100%;
  position: relative;
  transform: translateZ(0) scale(1);
  backface-visibility: hidden;
  transform-origin: 0 0; /* see note above */
}
.ldio-rpinwye8j0b div { box-sizing: content-box; }
<div
class="loadingio-eclipse">
  <div class="ldio-rpinwye8j0b">
    <div>
    </div>
  </div>
</div>