js---大风车呀转悠悠

js实现大风车旋转


 1. 点击开始风车开始旋转 
 2. 点击反转,风车进行逆时针旋转 
 3. 点击转一圈,则只会顺时针转一圈,输入转的圈数,则转指定圈数 
 4. 点击停止,风车停止转动

效果实现:
在这里插入图片描述

代码实现:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>大风车呀转悠悠</title>
    <style>
        .fc{
            animation:wm 1s infinite linear;
        }
        @keyframes wm {
            from {
                transform:rotate(0deg);
            }
            to {
                transform:rotate(-360deg);
            }
        }
        .reverse{
            animation:rer 1s infinite linear;
        }
        @keyframes rer {
            from {
                transform:rotate(-360deg);
            }
            to {
                transform:rotate(0deg);
            }
        }
    </style>
</head>
<body>
<div>
    <h3>大风车呀转悠悠</h3>
    <img src="img/logo.png" class="a" alt="" id="img1">
    <hr>
    <input type="button" value="开始" onclick="start1()">
    <input type="button" value="停止" onclick="stop1()">
    <input type="button" value="反转" onclick="reverse()">
    <input type="button" value="转1圈" onclick="circle(1)"><input type="text" size="1" value="" onblur="circle(this.value)"></div>
</body>
<script>
    //转起来
    function start1() {
        img1.className='fc'
    }
    //停下来
    function stop1() {
        img1.className=''
    }
    function reverse() {
        img1.className='reverse'
    }
    function circle(n) {
        let circle1 = document.getElementById("img1");
        circle1.className='fc'
        a=setTimeout(function (){
            stop1()
        },1000*n)
    }
</script>
</html>

很好玩哟,你确定不来试试吗?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值