您的位置:首页 > Web前端 > CSS

纯CSS实现圆环渐变过渡加载动画

2017-03-29 16:29 1781 查看
主要是从
CSS3
中的
linear-gradient
@keyframes
border-radius
等属性上下手, 兼容到
IE10


box1 和 box2
分别为左右两个渐变半圆,结合到一起就成了一整个渐变圆,
box3
圆的半径稍小,遮盖在整个渐变圆上,背景为白色,产生渐变圆环的效果。

效果图如下:



HTML:

<div class='box'>
<div class="box1"></div>
<div class="box2"></div>
<div class="box3"></div>
</div>


CSS:

/*旋转动画*/
@keyframes moveover {
0%   {transform:rotate(0deg);}
100% {transform:rotate(360deg);}
}
.box{
position:relative;
width:100px;
height:100px;
/*整体旋转*/
animation:moveover 3s linear infinite;
}
.box1{
position:absolute;
width: 50px;
height: 100px;
border-radius:50px 0 0 50px;
/* 起始最深颜色为 #999,过渡到中间颜色为 #d0cfcf */
background: linear-gradient(#999, #d0cfcf);
background-color: red;
z-index:2;
}
.box2{
position:absolute;
width: 50px;
height: 100px;
border-radius:0 50px 50px 0;
left:50%;
/* 过渡到中间颜色为 #d0cfcf 最终末尾颜色为 #eee */
background: linear-gradient(#eee,#d0cfcf);
z-index:1;
}
.box3{
position:absolute;
width:92px;
height:92px;
top:4px;
left:4px;
border-radius:50%;
background-color: #fff;
z-index:2;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: