css 3 制作水波状进度条

时间:2023-01-01 05:29:31

效果图如下 :

css 3 制作水波状进度条

代码如下:

 <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
@-webkit-keyframes spin {
from{-webkit-transform: rotate(0deg);transform: rotate(0deg);}
to{-webkit-transform: rotate(360deg);transform: rotate(360deg);}
}
@keyframes spin {
from{-webkit-transform: rotate(0deg);transform: rotate(0deg);}
to{-webkit-transform: rotate(360deg);transform: rotate(360deg);}
}
.wave-progress{width:200px;height:200px;margin:10px auto;border: 8px solid #fd6b65;border-radius:50%;background-color: #f8f8f8;box-sizing: border-box;position: relative;}
.wave-progress .inner{position: absolute;width:100%;height:100%;border-radius:50%;overflow: hidden; border: 6px solid #ffafac;box-sizing: border-box;z-index: 10}
.wave-progress .inner .water{position: absolute;width: 200%;height: 200%;left: -50%;border-radius: 40%;background:rgba(255,175,172,0.3);-webkit-animation:spin 10s linear infinite;animation:spin 10s linear infinite; }
.tips{color: #fd6b65;font-size: 28px;line-height: 184px;text-align: center;} </style>
</head>
<body>
<div class="wave-progress">
<div class="inner">
<div class="water"></div>
<div class="tips">1%</div>
</div>
</div>
</body>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.0.min.js"></script>
<script type="text/javascript">
var topNum = 100;
var timer = setInterval(function(){
$(".water").css({"top":topNum+"%"});
topNum -= 0.05;
var text = parseInt(100 - topNum)+"%";
$(".tips").text(text);
if(topNum <= 0){
clearInterval(timer);
}
},1);
</script>
</html>