移动的小狗

这篇博客展示了如何使用HTML和CSS创建一个移动的小狗动画。通过设置盒子的大小、边框、圆角、定位和层级,以及运用关键帧动画实现小狗的移动和变形效果。代码详细展示了各个部分(如耳朵、眼睛、身体等)的样式和位置,形成一只可爱的小狗形象,并在页面上循环移动。
摘要由CSDN通过智能技术生成

 一·、移动的小狗是利用html和css做出

  1. 利用的知识点:                
  • 盒子的的大小和边框圆角来构建盒子的形状
  • 盒子的定位来调整盒子的位置
  • z-index: ;调整盒子的层级

  • 动画来调整狗的移动和放大缩小

 代码如下:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body{
            background-color: #cccccc;
        }
        .dog{
            width:289px;
            height: 481px;
            margin-top: 150px;
            position: relative;
            animation:dog 20s linear 0s infinite alternate;
        }
        @keyframes dog {
            0%{
                left: 0;
                transform: scale(0.2);
            }
            25%{
                left: 200px;
                transform: scale(0.4);
            }
            50%{
                left: 400px;
                transform: scale(0.8);
            }
            75%{
               left: 600px;
               transform: scale(1);
            }
            100%{
                left: 800px;
                transform: scale(1.2);
            }
        }
        .Dogchains{
            width:479px;
            height:256px;
            border-left:#ff6b5a solid 6px;
            border-bottom:#ff6b5a solid 6px ;
            position: absolute;
            top:226px;
            left:205px;
            border-radius: 0 0 0 100px;
            z-index: 4;

        }
        .leftear{
            width: 55px;
            height: 116px;
            background-color:#6c3129;
            position: absolute;
            left: 55px;
            border-radius: 50% 50% 0 0;
        }
        .rightear{
            width: 55px;
            height: 116px;
            background-color:#6c3129;
            position: absolute;
            right:55px;
            border-radius: 50% 50% 0 0;
        }
        .body0{
            width: 180px;
            height: 447px;
            background-color:#e2aa23;
            border-radius: 100px 100px 0 0;
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            margin: 35px auto;
           z-index: 1;
        }
        .lefteye{
            width: 15px;
            height: 15px;
            background-color:#763f2f;
            border-radius: 50%;
            position: absolute;
            top: 51px;
            right:110px;
            z-index: 2;
        }
        .righteye{
            width: 15px;
            height: 15px;
            background-color:#763f2f;
            border-radius: 50%;
            position: absolute;
            top: 51px;
            left: 110px;
            z-index: 2;
        }
        .bridge{
            width: 30px;
            height: 34px;
            background-color:#fff;
            border-radius: 100px 100px 0 0;
            position: absolute;
            top:38px;
            left: 130px;
            z-index: 3;
        }
        .nose{
            width:30px;
            height:14px;
            background-color:#4a2425;
            border-radius: 0 0 100px 100px;
            position: absolute;
            top:68px;
            left: 130px;
            z-index: 3;
        }
        .cheek{
            width:84px;
            height:100px;
            background-color:#fff;
            border-radius: 85% 85% 100px 100px;
            position: absolute;
            top:72px;
            left: 103px;
            z-index: 2;
        }
        .mouth{
            width:45px;
            height:15px;
            background-color:#1a243c;
            border-radius: 0 0 100px 100px;
            position: absolute;
            top:105px;
            left:122px;
            z-index: 2;
        }
        .tongue{
            width:30px;
            height:50px;
            background-color:#ff6b5a;
            border-radius:5px 5px 15px 15px;
            position: absolute;
            top:110px;
            left:130px;
            z-index: 3;
        }
        .whiskers{
            width:43px;
            height:20px;
            background-color:#e4e6e7;
            border-radius:0px 0px 100px 100px;
            position: absolute;
            top:165px;
            left:125px;
            z-index: 3;
        }
        .sash{
            width: 180px;
            height: 46px;
            background-color:#ff6b5a;
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            margin: 195px auto;
           z-index: 2;
        }
        .Beltbigball{
            width: 50px;
            height: 50px;
            background-color:#ffc442;
            border-radius: 50%;
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            margin: 217px auto;
           z-index: 3;
        }
        .belly{
            width: 84px;
            height: 194px;
            background-color:#fff;
            border-radius: 100px 100px 0 0;
            position: absolute;
            left:103px;
            bottom: 0;
           z-index: 2;
        }
        .Beltballs{
            width: 16px;
            height: 16px;
            background-color:#fff;
            border-radius:50%;
            position: absolute;
            top:210px;
            left:47px;
        }
        .Beltballs1{
            width: 16px;
            height: 16px;
            background-color:#fff;
            border-radius:50%;
            position: absolute;
            top:210px;
            left:70px;
            z-index:3;
        }
        .Beltballs2{
            width: 16px;
            height: 16px;
            background-color:#fff;
            border-radius:50%;
            position: absolute;
            top:210px;
            left:170px;
            z-index:3;
        }
        .Beltballs3{
            width: 16px;
            height: 16px;
            background-color:#fff;
            border-radius:50%;
            position: absolute;
            top:210px;
            right:170px;
            z-index:3;
        }
        .Beltballs4{
            width: 16px;
            height: 16px;
            background-color:#fff;
            border-radius:50%;
            position: absolute;
            top:210px;
            right:70px;
            z-index:3;
        }
        .Beltballs5{
            width: 16px;
            height: 16px;
            background-color:#fff;
            border-radius:50%;
            position: absolute;
            top:210px;
            right:47px;
        }
        .tail{
            width: 20px;
            height: 106px;
            background-color: #934730;
            transform: rotate(45deg);
            position: absolute;
            bottom: 55px;
            right: 30px;
            border-radius: 100px 100px 0 0;
        }
        .leftleg{
            width: 19px;
            height: 64px;
            background-color: #a45f2e;
            position: absolute;
            bottom: 17px;
            left: 36px;
            border-radius: 100px 0 0 0;
        }
        .rightleg{
            width: 19px;
            height: 64px;
            background-color: #a45f2e;
            position: absolute;
            bottom: 17px;
            right: 36px;
            border-radius: 0 100px 0 0;
        }
        .foot{
            width: 289px;
            height: 17px;
            background-color: #a45f2e;
            border-radius: 100px 100px 0 0;
            position: absolute;
            bottom: 0;
        }
        .leftankle{
            width: 42px;
            height: 17px;
            background-color: #d18d2d;
            border-radius: 100px 100px 0 0;
            position: absolute;
            bottom: 0;
            left: 36px;
            z-index: 2;
        }
        .rightankle{
            width: 42px;
            height: 17px;
            background-color: #d18d2d;
            border-radius: 100px 100px 0 0;
            position: absolute;
            bottom: 0;
            right:36px;
            z-index: 2;
        }
    </style>
</head>
<body>
    <div class="dog"><!-- 狗整体 -->
        <div class="Dogchains"></div><!-- 狗链 -->
        <div class="leftear"></div><!-- 左耳朵 -->
        <div class="rightear"></div><!-- 右耳朵 -->
        <div class="body0"></div><!-- 身体 -->
        <div class="lefteye"></div><!-- 左眼 -->
        <div class="righteye"></div><!-- 右眼 -->
        <div class="nose"></div><!-- 鼻子 -->
        <div class="bridge"></div><!-- 鼻梁 -->
        <div class="cheek"></div><!-- 脸颊 -->
        <div class="mouth"></div><!-- 嘴 -->
        <div class="tongue"></div><!-- 舌头 -->
        <div class="whiskers"></div><!-- 胡须 -->
        <div class="sash"></div><!-- 腰带 -->
        <div class="Beltbigball"></div><!-- 腰带大球 -->
        <div class="Beltballs"></div><!-- 腰带小球 -->
        <div class="Beltballs1"></div><!-- 腰带小球 -->
        <div class="Beltballs2"></div><!-- 腰带小球 -->
        <div class="Beltballs3"></div><!-- 腰带小球 -->
        <div class="Beltballs4"></div><!-- 腰带小球 -->
        <div class="Beltballs5"></div><!-- 腰带小球 -->
        <div class="belly"></div><!-- 腹 -->
        <div class="tail"></div><!-- 尾巴 -->
        <div class="leftleg"></div><!-- 左腿 -->
        <div class="rightleg"></div><!-- 右腿 -->
        <div class="foot"></div><!-- 脚 -->
        <div class="leftankle"></div><!-- 左脚踝 -->
        <div class="rightankle"></div><!-- 右脚踝 -->
    </div>
</body>
</html>

效果如下:

QQ录屏20220713202648

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值