我只需要使用css和javascript制作一个饼形微调器/加载器。
到目前为止,当背景稳固时,我设法使其工作,因为它不需要看到隐藏半圆的div(不要介意颜色和顶部/左边):
.wrapper {
position: relative;
background: transparent;
width: 50px;
height: 50px;
background: gray;
}
.wrapper,
.wrapper * {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
.wrapper .pie,
.wrapper * .pie {
width: 50%;
height: 100%;
transform-origin: 100% 50%;
position: absolute;
background: red;
}
.wrapper .spinner,
.wrapper * .spinner {
border-radius: 100% 0 0 100%/50% 0 0 50%;
z-index: 200;
border-right: none;
animation: rota 5s linear infinite
}
.wrapper .filler,
.wrapper * .filler {
border-radius: 0 100% 100% 0/0 50% 50% 0;
left: 50%;
opacity: 0;
z-index: 100;
border-left: none;
background: red;
animation: opa 5s steps(1, end) infinite reverse
}
.wrapper .mask,
.wrapper * .mask {
width: 50%;
height: 100%;
position: absolute;
background: inherit;
opacity: 1;
z-index: 300;
animation: opa 5s steps(1, end) infinite
}
.wrapper:hover .spinner,
.wrapper:hover .filler,
.wrapper:hover .mask {
animation-play-state: running;
}
@-moz-keyframes rota {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
@-webkit-keyframes rota {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
@-o-keyframes rota {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
@keyframes rota {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
@-moz-keyframes opa {
0% {
opacity: 1;
}
50%,
100% {
opacity: 0;
}
}
@-webkit-keyframes opa {
0% {
opacity: 1;
}
50%,
100% {
opacity: 0;
}
}
@-o-keyframes opa {
0% {
opacity: 1;
}
50%,
100% {
opacity: 0;
}
}
@keyframes opa {
0% {
opacity: 1;
}
50%,
100% {
opacity: 0;
}
}

<div class="wrapper">
<div class="pie spinner"></div>
<div class="pie filler"></div>
<div class="mask"></div>
</div>
&#13;
问题是,我需要让背景透明,所以我可以看到它,但是然后掩码div变得无用:
body {
background-image: url(http://www.publicdomainpictures.net/pictures/20000/velka/tulip-flower-garden.jpg)
}
.wrapper {
position: relative;
background: transparent;
width: 50px;
height: 50px;
background: transparent;
}
.wrapper,
.wrapper * {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
.wrapper .pie,
.wrapper * .pie {
width: 50%;
height: 100%;
transform-origin: 100% 50%;
position: absolute;
background: red;
}
.wrapper .spinner,
.wrapper * .spinner {
border-radius: 100% 0 0 100%/50% 0 0 50%;
z-index: 200;
border-right: none;
animation: rota 5s linear infinite
}
.wrapper .filler,
.wrapper * .filler {
border-radius: 0 100% 100% 0/0 50% 50% 0;
left: 50%;
opacity: 0;
z-index: 100;
border-left: none;
background: red;
animation: opa 5s steps(1, end) infinite reverse
}
.wrapper .mask,
.wrapper * .mask {
width: 50%;
height: 100%;
position: absolute;
background: inherit;
opacity: 1;
z-index: 300;
animation: opa 5s steps(1, end) infinite
}
.wrapper:hover .spinner,
.wrapper:hover .filler,
.wrapper:hover .mask {
animation-play-state: running;
}
@-moz-keyframes rota {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
@-webkit-keyframes rota {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
@-o-keyframes rota {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
@keyframes rota {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
@-moz-keyframes opa {
0% {
opacity: 1;
}
50%,
100% {
opacity: 0;
}
}
@-webkit-keyframes opa {
0% {
opacity: 1;
}
50%,
100% {
opacity: 0;
}
}
@-o-keyframes opa {
0% {
opacity: 1;
}
50%,
100% {
opacity: 0;
}
}
@keyframes opa {
0% {
opacity: 1;
}
50%,
100% {
opacity: 0;
}
}
&#13;
<div class="wrapper">
<div class="pie spinner"></div>
<div class="pie filler"></div>
<div class="mask"></div>
</div>
&#13;
有可能实现我想要的吗?怎么样?
答案 0 :(得分:0)
div.aio-icon:hover.advanced.faceboook {
border-color: #3b5996;
background-color: #3b5996;
}
div.aio-icon:hover.advanced.twitter {
border-color: #29c5f6;
background-color: #29c5f6;
}
div.aio-icon:hover.advanced.instagram {
border-color: #b16c4f;
background-color: #b16c4f;
}
div.aio-icon:hover.advanced.youtube{
border-color: #f0251d;
background-color: #f0251d;
}
div.aio-icon:hover.advanced.soundcloud{
border-color: #ff6d00;
background-color: #ff6d00;
}
&#13;
.wrapper {
position: relative;
background: transparent !important;
width: 50px;
height: 50px;
background: gray;
}
.wrapper,
.wrapper * {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
.wrapper .pie,
.wrapper * .pie {
width: 50%;
height: 100%;
transform-origin: 100% 50%;
position: absolute;
background: red;
}
.wrapper .spinner,
.wrapper * .spinner {
border-radius: 100% 0 0 100%/50% 0 0 50%;
z-index: 200;
border-right: none;
animation: rota 5s linear infinite
}
.wrapper .filler,
.wrapper * .filler {
border-radius: 0 100% 100% 0/0 50% 50% 0;
left: 50%;
opacity: 0;
z-index: 100;
border-left: none;
background: red;
animation: opa 5s steps(1, end) infinite reverse
}
.wrapper .mask,
.wrapper * .mask {
width: 50%;
height: 100%;
position: absolute;
background: inherit;
opacity: 1;
z-index: 300;
animation: opa 5s steps(1, end) infinite
}
.wrapper:hover .spinner,
.wrapper:hover .filler,
.wrapper:hover .mask {
animation-play-state: running;
}
@-moz-keyframes rota {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
@-webkit-keyframes rota {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
@-o-keyframes rota {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
@keyframes rota {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
@-moz-keyframes opa {
0% {
opacity: 1;
}
50%,
100% {
opacity: 0;
}
}
@-webkit-keyframes opa {
0% {
opacity: 1;
}
50%,
100% {
opacity: 0;
}
}
@-o-keyframes opa {
0% {
opacity: 1;
}
50%,
100% {
opacity: 0;
}
}
@keyframes opa {
0% {
opacity: 1;
}
50%,
100% {
opacity: 0;
}
}
&#13;
添加背景transprent important
<div class="wrapper">
<div class="pie spinner"></div>
<div class="pie filler"></div>
<div class="mask"></div>
</div>