用一个铺满蓝色的背景的盒子,
利用::before与after画2个圆角值不同的不规则圆形(其中一个设置透明度或者其他颜色,以便区分):
父元素设置overflow:hidden;
最后加上animation 动画让不同规则圆形旋转起来即可:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div class="wave"></div>
</body>
<style>
/* // 简单的盒子 */
.wave {
position: relative
width: 150px
height: 150px
background-color: #5291e0
/* overflow: hidden*/
}
/* // 两个不规则圆形(相对盒子进行定位,距离底部距离则为波浪高度) */
.wave::before,
.wave::after {
content: ""
position: absolute
left: 50%
bottom: 15%
width: 500%
height: 500%
border-radius: 45%
background-color: #fff
transform: translateX(-50%)
animation: rotate 15s linear infinite
}
/* // 其中一个不规则圆形调整一下样式,以便区分(或者调整animation的参数来区分) */
.wave::before {
bottom: 10%
opacity: .5
border-radius: 47%
}
/* // 旋转动画 */
@keyframes rotate {
from {
transform: translateX(-50%) rotateZ(0deg)
}
to {
transform: translateX(-50%) rotateZ(360deg)
}
}
</style>
</html>
一、实现CSS3无限循环动画代码示例。
代码如下:
CSS:
@-webkit-keyframes gogogo {
0%{
-webkit-transform: rotate(0deg)
border:5px solid red
}
50%{
-webkit-transform: rotate(180deg)
background:black
border:5px solid yellow
}
100%{
-webkit-transform: rotate(360deg)
background:white
border:5px solid red
}
}
.loading{
border:5px solid black
border-radius:40px
width: 28px
height: 188px
-webkit-animation:gogogo 2s infinite linear
margin:100px
}
扩展资料实现动画无限循环所需要的CSS属性说明:
1、infinite
在animation后面加上infinite就可以无限循环,另外还可以做反向循环使用animation-direction
2、animation-name
规定需要绑定到选择器的 keyframe 名称。
3、animation-duration
规定完成动画所花费的时间,以秒或毫秒计。
4、animation-timing-function
规定动画的速度曲线。
5、animation-delay
规定在动画开始之前的延迟。
6、animation-iteration-count
规定动画应该播放的次数。
7、animation-direction
规定是否应该轮流反向播放动画。