<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script>
<style>
*{margin: 0;padding: 0}
.container{
position: relative;
width: 600px;
margin-left: auto;
margin-right: auto;
}
.handle{
width: 120px;
height: 200px;
position: absolute;
top: 10px;
left: 117px;
z-index: 101;
transform: rotate(-30deg);
transform-origin: 30px 30px; //旋转中心点
}
.pan{
width: 300px;
height: 300px;
position: absolute;
top: 125px;
}
.click{
height: 50px;
width: 50px;
border-radius: 50%;
position: absolute;
top: 250px;
left: 125px;
z-index: 110;
}
.play{
animation: play 2s linear infinite;
animation-play-state: running;
}
.unplay{
animation-play-state: paused;
}
.move{
animation: move 2s forwards;
}
.unmove{
animation: unmove 2s forwards;
}
@keyframes move{
0%{
transform:rotate(-30deg)
}
100%{
transform: rotate(0deg)
}
}
@keyframes unmove{
0%{
transform: rotate(0deg)
}
100%{
transform: rotate(-30deg)
}
}
@keyframes play{
0%{
transform: rotate(360deg)
}
}
@keyframes unplay{
0%{
transition: rotate(0deg)
}
}
/* animation-fill-mode:forwards;
backwards:动画结束时会回到开始位置
forwards:动画会在结束位置停止
*/
</style>
<div class="container">
<img class="pan " src="images/pan.png" alt="">
<img class="handle " src="images/shou.png" alt="">
<img class="click" src="images/播放.jpg" alt="">
</div>
<script>
var isPlay=false;
$(".click").click(function(){
isPlay=!isPlay;
if(isPlay){
$(".handle").addClass("move").removeClass("unmove");
$(".pan").addClass("play").removeClass("unplay")
}else{
$(".handle").removeClass("move").addClass("unmove");
$(".pan").removeClass("play").addClass("unplay")
}
})
</script>
课件地址:
https://gitee.com/wangsiman/wuhannotebook/blob/master/javascript/js-day13/03music.html