用纯css做出表情可动的哆啦a梦

因为从小就喜欢哆啦a梦,但因为不会画画一直想要画一个哆啦a梦的梦想也没有实现。直到现在学习了编程后就想到我能不能就用css编写一个哆啦a梦出来呢,想到这里,咱们说干就干

先把htm部分写好

<!DOCTYPE html>
<html lang="en">
<head>
    <link rel="stylesheet" href="./dola.css">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=, initial-scale=1.0">
    <title>哆啦a梦</title>
</head>
<body>
    <div class="doa">
<div class="head">
<div class="face">
<div>
    <div> <p></p> </div>
</div>
<div>
<div> <p></p> </div>
</div>
</div>

<div class="nose">  
    <p>  </p>
</div>

<div class="nose1">  </div>

<div class="mouth">  </div>

<div class="beard">  </div>
<div class="beard1"> </div>
<div class="beard2"> </div>
<div class="beard3"> </div>
<div class="beard4"> </div>
<div class="beard5"> </div>

</div>
    </div>
    <div class="neck"> 
        <p></p>
        <p></p>
        <p></p>
        <p></p>
        </div>

</body>
</html>

因为我当时写的时候也没有写注释,不过类名用的英语代表各个不同的部位

第二部分就是最重要的css样式了

.doa{
position: relative;
top: 260px;
}
.head{
margin:0 auto ;
width: 400px;
height: 350px;
background-color: #008ee3;
position: relative;
border-radius: 55% 55% 50% 50%;
border: 2px solid;
}
.face{
width: 310px;
height: 260px;
background-color: snow;
border-radius: 55% 55% 45% 45%;
position: relative;
top: 90px;
left: 45px;
}
.face>div:first-child{
width: 80px;
height: 100px;
border-radius: 50%;
border: 2px #000 solid;
background-color: snow;
float: left;
position: relative;
top: -40px;
left: 71px;
z-index: 50;
}
.face>div:last-child{
width: 80px;
height: 100px;
border-radius: 50%;
border: 2px #000 solid;
background-color: snow;
float: left;
top: -40px;
left: 71px;
position: relative;
z-index: 50;
}
.face>div:first-child div {
width: 20px;
height: 25px;
background-color: #000;
border-radius: 50%;
position: absolute;
top: 45px;
left: 60px;
transition: all 1s;
}
.face>div:first-child div p{
width: 10px;
height: 10px;
border-radius: 50%;
background-color: #ffffff;
position:absolute;
top: -3px;
left: 10px;
}
.face>div:last-child div {
width: 20px;
height: 25px;
background-color: #000;
border-radius: 50%;
position: absolute;
top: 45px;
right: 60px;
}
    .face>div:last-child div p{
width: 10px;
height: 10px;
border-radius: 50%;
background-color:#ffffff;
position:absolute;
top: -3px;
left: 3px;
}   
.nose{
width: 30px;
height: 30px;
border-radius: 50%;
background-color: #c70000;
position: absolute;
top: 130px;
left: 50%;
margin-left: -15px;
z-index: 10;
}
.nose p{
width: 10px;
height: 10px;
border-radius: 50%;
position: absolute;
background-color: #ffffff;
top: -3px;
margin-left: 20px;
z-index: 10;
}
.nose1{
width: 2px;
height: 130px;
background-color: #000;
position: absolute;
top: 160px;
left: 50%;
margin-left: -1px;
z-index: 10;
}
.mouth{
width: 250px;
height: 200px;
border-radius: 50%;
background-color: snow;
border-bottom: 2px #000 solid;
margin:-230px auto;
position: relative;
top: 78px;
transition: all 1s;
}
.beard{
width: 120px;
height: 40px;
border-top: 2px #000 solid;
border-radius: 10% 90%;
position: absolute;
left: 50%;
top: 150px;
margin-left: -170px;
z-index: 100;
}
.beard1{
width: 120px;
height: 40px;
border-top: 2px #000 solid;
border-radius: 10% 90% 10% 90%;
position: absolute;
left: 50%;
top: 180px;
margin-left: -170px;
z-index: 100px;
}
.beard2{
    width: 120px;
    height: 40px;
    border-top: 2px #000 solid;
    border-radius: 10% 90% 10% 90%;
    position: absolute;
    left: 50%;
    top: 210px;
    margin-left: -170px;
    z-index: 100px;
    }
.beard3{
        width: 120px;
        height: 40px;
        border-top: 2px #000 solid;
        border-radius: 90% 10% 90% 10%;
        position: absolute;
        left: 50%;
        top: 150px;
        margin-left: 50px;
        z-index: 100;
        }
.beard4{
        width: 120px;
        height: 40px;
        border-top: 2px #000 solid;
        border-radius: 90% 10% 90% 10%;
        position: absolute;
        left: 50%;
        top: 180px;
        margin-left: 50px;
        z-index: 100px;
        }
 .beard5{
            width: 120px;
            height: 40px;
            border-top: 2px #000 solid;
            border-radius: 90% 10% 90% 10%;
            position: absolute;
            left: 50%;
            top: 210px;
            margin-left: 50px;
            z-index: 100px;
            }  

.neck{
width: 330px;
height: 200px;
border-radius: 50%  50% 50% 50%; 
background: #e30000;
margin: 80px auto;
z-index: 100;
border: 2px solid;
}        
.neck p:first-child{
border: 2px #000 solid;
border-radius: 50%;
width: 40px;
height: 40px;
background: #ffdd2e;
position: absolute;
left: 50%;
margin-left: -22px;
transition: all 1s;
top: 600px;
}    
.neck p:nth-child(2){
border: 2px #000 solid;
border-radius: 5px;
width: 44px;
height: 5px;
background: #ffdd2e;
position: absolute;
left: 50%;
margin-left: -24px;
transition: all 1s;
top: 615px;
}
.neck p:nth-child(3){
border: 2px #000 solid;
border-radius: 50%;
width: 8px;
height: 8px;
background: #6c5844;
position: absolute;
left: 50%;
margin-left: -6px;
transition: all 1s;
top: 625px;
}
.neck p:nth-child(4){
    width: 2px;
    height: 8px;
    background: #000;
    position: absolute;
    left: 50%;
    margin-left: -1px;
    transition: all 1s;
    top: 635px;
    }
.neck:hover p:first-child{
width: 60px;
height: 60px;
left: 50%;
margin-left: -30px;
}
.neck:hover p:nth-child(2){
width: 66px;
height: 7.5px;
left: 50%;
margin-left: -33px;
top: 625px;
}
.neck:hover p:nth-child(3){
width: 12px;
height: 12px;
left: 50%;
margin-left: -6px;
top: 635px;
    }
.neck:hover p:nth-child(4){
width: 2px;
height: 12px;
left: 50%;
margin-left: 1px;
top: 649px;
        }   
.mouth:hover{
border-radius: 10%;
width: 180px;
height: 200px;
transition: all 1s;
}       
:hover.face>div:first-child div{
left: 0px;
transition: all 1s;
}

css样式较多,但都并不复杂,各位就可以理解为用css画画了,静下心来慢慢看还是很好理解的

那么这次就先分享到这里,喜欢的各位可以点个赞哦

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值