<div class="face">
<div class="eye left">
<div class="brow-left"></div>
</div>
<div class="eye right">
<div class="brow-right"></div>
</div>
<div class="mouth"> </div>
</div>
HTML
格式化
支持Emmet,输入 p 后按 Tab键试试吧!
<head> ... </head>
<body>
</body>
CSS
格式化
html, body{
margin: 0px;
padding: 0px;
}
:root{
--size : 200px;
--eye-width : 70px;
--eye-height : 10px;
--mouth-width : 160px;
--mouth-height : 160px;
}
.face{
width: var(--size);
height: var(--size);
background-color: yellow;
border-radius: 50%;
position: relative;
/* border: 3px solid #000; */
}
.face{
margin: 20px auto;
}
.face{
/* animation: jumpAnima 1s infinite linear; */
}
@keyframes jumpAnima{
0%{
/* transform: translateY(0px) scaleY(0.5) rotate(0deg); */
transform: rotate(0deg);
}
50%{
/* transform: translateY(-150px) scaleY(1.5) rotate(180deg); */
transform: rotate(180deg);
}
100%{
/* transform: translateY(0px) scaleY(0.5) rotate(360deg); */
transform: rotate(360deg);
}
}
.eye{
width: var(--eye-width);
height: var(--eye-height);
background-color: #fff;
border: 3px solid #888;
border-radius: 50%;
position: absolute;
top: 30%;
box-shadow: 0px 25px 3px -3px rgb(240, 174, 174);
}
.eye::before{
content: ' ';
width: 10px;
height: 10px;
border-radius: 50%;
background-color: #000;
display: inline-block;
position: absolute;
left: 10px;
}
.left{
left: 10px;
}
.right{
right:10px;
}
.mouth{
width: var(--mouth-width);
height: var(--mouth-width);
border-radius: 50%;
/* background-color: #000; */
box-shadow: 0px 6px 0px 0px rgb(120, 74, 8);
position: absolute;
left: 50%;
bottom: 30px;
transform: translateX(-50%);
}
.brow-left, .brow-right{
width: 30px;
height: 20px;
position: absolute;
top: -35px;
border-radius: 50%;
}
.brow-left{
/* border-top-right-radius: 8px; */
/* border-right: 3px solid #000; */
/* border-top: 3px solid #000; */
right: 6px;
transform: rotate(-135deg);
box-shadow: 4px 4px 0px -2px rgb(120, 74, 8);
}
.brow-right{
/* border-top-left-radius: 8px; */
/* border-left: 3px solid #000;
border-top: 3px solid #000; */
left: 6px;
transform: rotate(135deg);
box-shadow: -4px 4px 0px -2px rgb(120, 74, 8);
}
JS
格式化