行走小动画案例扩展

简介: 行走小动画案例扩展

<!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>
     <style>
         .box{
            border: 1px black solid;
            height: 180px;
            width: 120px;
            margin: 0 auto;
            position: relative;
            overflow: hidden;
        }
        .box img{
            position: absolute;
            left: 0px;
            top: 0px;
        }
        button{
            height: 30px;
            width: 30px;
            position:absolute ;
            top:200px;
            margin-top: 70px;
            left:50%;
            margin-left: -150px;
            border-radius: 50%;
            border: none;
outline: none;
            font-size: 20px;
        }
        #butn2{
            top:200px;
            margin-top: 70px;
            left:50%;
            margin-left:100px;
        }
    </style>
    <script>
        window.onload = function(){
            var oImg = document.getElementById('img01');
            var num = 0;
            var speed = 120;
            var oTimer = null;
            oTimer = setInterval(fnMove,120)
            function fnMove(){
                num -= speed
                if(num<-860){
                    num = 0
                }
                if(num>0){
                    num = -840
                }
                oImg.style.left = num + 'px'
            }
            var oButn1 = document.getElementById('butn1')
            var oButn2 = document.getElementById('butn2')
            oButn1.onclick = function(){
                speed = 120
            }
            oButn2.onclick = function(){
                speed = -120
            }
            oImg.onmouseover = function(){
                clearInterval(oTimer)
            }
            oImg.onmouseout = function(){
                oTimer = setInterval(fnMove,120)
            }
        }
    </script>
</head>
<body>
    <img src="images/walking.png" alt="行走图片">
    <button id="butn1">&lt;</button>
    <div class="box">    
        <img src="images/walking.png" alt="行走图片" id="img01">      
    </div>
    <button id="butn2">&gt;</button>
</body>
</html>


相关文章
|
存储 应用服务中间件 网络安全
使用 Ansible 部署 Elasticsearch 集群
使用 Ansible 部署 Elasticsearch 集群
1095 0
使用 Ansible 部署 Elasticsearch 集群
|
域名解析 缓存 JavaScript
手把手教你从零开始搭建个人博客,20分钟上手
手把手教你从零开始搭建个人博客,20分钟上手
666 0
手把手教你从零开始搭建个人博客,20分钟上手
Component
Component
318 0
Component
|
SQL Oracle 关系型数据库
|
3天前
|
云安全 人工智能 算法
以“AI对抗AI”,阿里云验证码进入2.0时代
三层立体防护,用大模型打赢人机攻防战
1307 3
|
3天前
|
机器学习/深度学习 安全 API
MAI-UI 开源:通用 GUI 智能体基座登顶 SOTA!
MAI-UI是通义实验室推出的全尺寸GUI智能体基座模型,原生集成用户交互、MCP工具调用与端云协同能力。支持跨App操作、模糊语义理解与主动提问澄清,通过大规模在线强化学习实现复杂任务自动化,在出行、办公等高频场景中表现卓越,已登顶ScreenSpot-Pro、MobileWorld等多项SOTA评测。
629 3
|
4天前
|
人工智能 Rust 运维
这个神器让你白嫖ClaudeOpus 4.5,Gemini 3!还能接Claude Code等任意平台
加我进AI讨论学习群,公众号右下角“联系方式”文末有老金的 开源知识库地址·全免费
|
10天前
|
编解码 人工智能 自然语言处理
⚽阿里云百炼通义万相 2.6 视频生成玩法手册
通义万相Wan 2.6是全球首个支持角色扮演的AI视频生成模型,可基于参考视频形象与音色生成多角色合拍、多镜头叙事的15秒长视频,实现声画同步、智能分镜,适用于影视创作、营销展示等场景。
742 5