先上图
css实现机器猫
代码
<!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{
margin: 0;
background-color: aquamarine;
}
.wrap{
margin: 50px auto;
border: 1px solid;
width: 586px;
height: 650px;
position: relative;
animation: wrapexample 2s linear infinite;
}
@keyframes wrapexample{
0%{background-color: chartreuse;}
25%{background-color: rgb(241, 238, 9);}
50%{background-color: rgb(243, 125, 7);}
75%{background-color: rgb(16, 192, 245);}
100%{background-color: rgb(216, 25, 82);}
}
.header{
width: 370px;
height: 350px;
border: 1px solid;
border-radius: 50%;
background-color: #0096ea;
margin: auto;
animation: headexample 2s linear infinite;
position: relative;
}
@keyframes headexample{
0%{transform: rotate(360deg)}
}
.face{
width: 300px;
height: 280px;
border: 1px solid;
border-radius: 50%;
background-color: white;
position: absolute;
bottom: 0;
left: 0;
right: 0;
margin: auto;
}
.eyeleft{
width: 77px;
height: 100px;
border: 1px solid;
background-color: white;
border-radius: 50%;
position: absolute;
top: 2%;
left: 28%;
}
.eyeright{
width: 77px;
height: 100px;
border: 1px solid;
background-color: white;
border-radius: 50%;
position: absolute;
top: 1%;
right: 30%;
}
.eyeleft::before,
.eyeright::before{
content: "";
display: block;
width: 30px;
height: 33px;
background-color: black;
border: 1px solid;
border-radius: 50%;
position: absolute;
top: 38%;
left: 32%;
animation: eyeexample 2s linear infinite;
}
@keyframes eyeexample{
0%{transform: translateY(9px);}
100%{transform: translateY(-9px);}
}
.nose{
width: 58px;
height: 58px;
border: 1px solid;
border-radius: 50%;
background-color: red;
position: absolute;
top: 20%;
left: 41%;
z-index: 3;
}
.nose::before{
content: "";
width: 22px;
height: 22px;
position: absolute;
border: 1px solid;
border-radius: 50%;
background-color: white;
top: 25%;
left: 29%;
}
.nose-line{
width: 0;
height: 200px;
border: 1px solid;
position: absolute;
top: 23%;
left: 49%;
z-index: 2;
}
.mouse{
width: 270px;
height: 200px;
border: 2px solid;
border-radius: 50%;
position: absolute;
border-top: transparent;
border-left: transparent;
border-right: transparent;
top: 23%;
left: 13%;
}
.huzi{
width: 205px;
height: 110px;
/* border: 1px solid; */
position: absolute;
top: 33%;
left: 22%;
}
.huzi>p{
width: 90px;
border: 1px solid;
position: absolute;
}
.huzi>p:nth-child(1){
top: 3%;
right: 3%;
transform: rotate(162deg);
}
.huzi>p:nth-child(2){
top: 33%;
right: 3%;
transform: rotate(0deg);
}
.huzi>p:nth-child(3){
top: 66%;
right: 3%;
transform: rotate(-162deg);
}
.huzi>p:nth-child(4){
top: 3%;
left: 0%;
transform: rotate(198deg);
}
.huzi>p:nth-child(5){
top: 33%;
left: 0%;
transform: rotate(360deg);
}
.huzi>p:nth-child(6){
top: 66%;
left: 0%;
transform: rotate(164deg);
}
.section{
width: 183px;
height: 153px;
background-color: #0096ea;
position: relative;
top: -4%;
left: 35%;
z-index: 10;
}
.section::before{
content: "";
display: block;
width: 100%;
height: 13px;
background-color: red;
position: absolute;
z-index: 12;
}
.bell{
width: 40px;
height: 40px;
border: 1px solid;
border-radius: 50%;
background-color: yellow;
position: absolute;
left: 36%;
top: 4%;
z-index: 11;
}
.bell>.tu{
width: 37px;
height: 10px;
border: 1px solid;
position: absolute;
border-radius: 50%;
top: 20%;
}
.bell>.yu{
width: 10px;
height: 10px;
border: 1px solid;
position: absolute;
border-radius: 50%;
top: 61%;
left: 36%;
background-color: black;
}
.bell>.xian{
width: 0px;
height: 4px;
border: 1px solid;
position: absolute;
top: 85%;
left: 49%;
background-color: black;
}
.dz{
width: 170px;
height: 150px;
background-color: white;
border: 1px solid;
border-radius: 50%;
position: absolute;
left: 3%;
}
.dz::before{
content: "";
display: block;
width: 109px;
height: 56px;
border: 1px solid;
border-bottom-left-radius: 65%;
border-bottom-right-radius: 65%;
position: absolute;
top: 51%;
left: 18%;
}
.armleft{
width: 90px;
height: 41px;
position: relative;
border: 1px solid;
background-color: #0096ea;
top: -23%;
left: 21%;
border-bottom-left-radius: 74%;
transform-origin: 100% 50%;
animation: example 2s linear infinite;
}
@keyframes example {
0% { transform: rotate(-20deg); }
25% { transform: rotate(0deg); }
50% { transform: rotate(20deg); }
75% { transform: rotate(0deg); }
100% { transform: rotate(-20deg); }
}
.armleft::before{
content: "";
display: block;
width: 50px;
height: 50px;
border: 1px solid;
border-radius: 50%;
background-color: white;
position: absolute;
top: -23%;
left: -14%;
}
.armright{
width: 90px;
height: 41px;
position: relative;
border: 1px solid;
background-color: #0096ea;
top: -30%;
left: 64%;
border-bottom-right-radius: 74%;
}
.armright::before{
content: "";
display: block;
width: 50px;
height: 50px;
border: 1px solid;
border-radius: 50%;
background-color: white;
position: absolute;
top: -16%;
left: 58%;
}
.leftfoot{
width: 116px;
height: 80px;
border: 1px solid;
background-color: #0096ea;
border-radius: 50%;
position: relative;
top: -23%;
left: 27%;
z-index: 14;
}
.rightfoot{
width: 116px;
height: 80px;
border: 1px solid;
background-color: #0096ea;
border-radius: 50%;
position: relative;
top: -35%;
left: 52%;
z-index: 14;
}
.yufoot{
width: 65px;
height: 97px;
border: 1px solid;
border-radius: 50%;
position: relative;
background-color: aliceblue;
top: -50%;
left: 44%;
z-index: 14;
}
</style>
</head>
<body>
<div class="wrap">
<div class="header">
<div class="face"></div>
<div class="eyeleft"></div>
<div class="eyeright"></div>
<div class="nose"></div>
<div class="nose-line"></div>
<div class="mouse"></div>
<div class="huzi">
<p></p>
<p></p>
<p></p>
<p></p>
<p></p>
<p></p>
</div>
</div>
<div class="section">
<div class="bell">
<div class="tu"></div>
<div class="yu"></div>
<div class="xian"></div>
</div>
<div class="dz"></div>
</div>
<div class="armleft"></div>
<div class="armright"></div>
<div class="leftfoot"></div>
<div class="rightfoot"></div>
<div class="yufoot"></div>
</div>
</body>
</html>