涉及知识点
1.定位:子绝父相
2.border-radius 画圆、半圆
3.transform:rotate(15deg)调整线条角度
4.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>
.bg {
position: relative;
width: 325px;
height: 400px;
background-color: white;
margin: 0 auto;
border: 1px dotted black;
}
.top {
width: 100%;
height: 245px;
overflow: hidden;
}
.head {
position: relative;
width: 275px;
height: 275px;
border-radius: 50%;
background-color: rgb(19, 171, 194);
margin: 0 auto;
}
.head2 {
position: absolute;
top: 30px;
left: 15px;
width: 245px;
height: 245px;
border-radius: 50%;
background-color: white;
}
.eye-left {
position: absolute;
top: -15px;
left: 74px;
width: 45px;
height: 45px;
border-radius: 50%;
border: 1px solid black;
background-color: white;
}
.eye-right {
position: absolute;
top: -15px;
left: 121px;
width: 45px;
height: 45px;
border-radius: 50%;
border: 1px solid black;
background-color: white;
}
.eye-left-inner {
position: absolute;
top: 15px;
left: 23px;
width: 15px;
height: 15px;
border-radius: 50% 50% 0 0 / 100% 100% 0 0;
border: 1px solid rgb(10, 6, 6);
border-bottom: transparent;
}
.eye-right-inner {
position: absolute;
top: 10px;
left: 6px;
width: 13px;
height: 25px;
border-radius: 50% 50% 50% 50%;
background-color: black;
}
.eye-right-inner2 {
position: absolute;
top: 17px;
left: 6px;
width: 7px;
height: 10px;
border-radius: 50% 50%;
background-color: white;
}
.nose {
position: absolute;
top: 15px;
left: 102px;
width: 35px;
height: 35px;
border-radius: 50%;
background-image: radial-gradient(pink 0, red);
}
.nose-line {
position: absolute;
top: 50px;
left: 120px;
width: 1px;
height: 115px;
background-color: black;
}
.hu1,
.hu1-r,
.hu2,
.hu2-r,
.hu3,
.hu3-r {
position: absolute;
top: 74px;
left: 4px;
transform: rotate(15deg);
width: 78px;
height: 1px;
background-color: black;
}
.hu1-r {
left: 160px;
transform: rotate(-15deg);
}
.hu2 {
top: 98px;
transform: rotate(-5deg);
}
.hu2-r {
left: 160px;
top: 98px;
transform: rotate(5deg);
}
.hu3 {
top: 118px;
transform: rotate(-15deg);
}
.hu3-r {
left: 160px;
top: 118px;
transform: rotate(15deg);
}
.mouth {
position: absolute;
top: 98px;
left: 18px;
width: 200px;
height: 70px;
border-radius: 70%;
border-width: 1px;
border-style: solid;
border-color: transparent transparent black transparent;
}
.mid {
z-index: 5;
position: absolute;
top: 240px;
left: 65px;
width: 191px;
height: 12px;
border-radius: 5px;
background-color: rgb(241, 93, 118);
}
.bell {
position: absolute;
top: 0;
left: 81px;
width: 27px;
height: 27px;
background-image: radial-gradient(rgb(144, 144, 24) 0 30%, yellow 20% 100%);
border-radius: 50%;
}
.v-line {
position: absolute;
top: 19px;
left: 95px;
width: 1px;
height: 9px;
background-color: black;
}
.body {
position: absolute;
z-index: 4;
top: 252px;
left: 65px;
width: 191px;
height: 110px;
border-radius: 5px;
border-bottom: 1px solid black;
border-left: 1px solid black;
border-right: 1px solid black;
background-color: rgb(19, 171, 194);
}
.circle1 {
position: absolute;
z-index: 4;
top: 0;
left: 15px;
width: 160px;
height: 80px;
background: white;
border-radius: 0 0 50% 50% / 0 0 100% 100%;
}
.circle2 {
position: absolute;
z-index: 5;
top: 18px;
left: 33px;
width: 120px;
height: 50px;
background: white;
border-width: 1px;
border-style: solid;
border-color: black;
border-radius: 0 0 50% 50% / 0 0 100% 100%;
}
.circle3 {
position: absolute;
top: 103px;
left: 87px;
width: 15px;
height: 7px;
border-radius: 50% 50% 0 0 / 100% 100% 0 0;
border: 1px solid black;
border-color: black transparent transparent transparent;
background-color: white;
}
.left-line {
position: absolute;
top: 0;
left: -1px;
width: 3px;
height: 27px;
background-color: rgb(19, 171, 194);
}
.right-line {
position: absolute;
top: 1px;
left: 189px;
width: 3px;
height: 27px;
background-color: rgb(19, 171, 194);
}
.left-hand {
position: absolute;
z-index: 2;
top: 260px;
left: 21px;
width: 67px;
height: 33px;
transform: rotate(-30deg);
border: 1px solid black;
background-color: rgb(19, 171, 194);
}
.left-hand-circle {
position: absolute;
top: -5px;
left: -25px;
width: 40px;
height: 40px;
border-radius: 50%;
background: white;
border: 1px solid black;
}
.right-hand {
position: absolute;
z-index: 2;
top: 260px;
left: 231px;
width: 67px;
height: 33px;
transform: rotate(210deg);
border: 1px solid black;
background-color: rgb(19, 171, 194);
}
.right-hand-circle {
position: absolute;
top: -5px;
left: -25px;
width: 40px;
height: 40px;
border-radius: 50%;
background: white;
border: 1px solid black;
}
.left-footer,
.right-footer {
position: absolute;
z-index: 4;
top: 360px;
left: 57px;
width: 100px;
height: 12px;
background-color: white;
border-radius: 5px;
border: 1px solid black;
}
.right-footer {
left: 165px;
}
</style>
</head>
<body>
<div class="bg">
<div class="top">
<div class="head">
<div class="head2">
<div class="eye-left">
<div class="eye-left-inner"></div>
</div>
<div class="eye-right">
<div class="eye-right-inner"></div>
<div class="eye-right-inner2"></div>
</div>
<div class="nose">
</div>
<div class="nose-line"></div>
<div class="hu1"></div>
<div class="hu1-r"></div>
<div class="hu2"></div>
<div class="hu2-r"></div>
<div class="hu3"></div>
<div class="hu3-r"></div>
<div class="mouth"></div>
</div>
</div>
</div>
<div class="mid">
<div class="bell"></div>
<div class="v-line"></div>
</div>
<div class="body">
<div class="circle1"></div>
<div class="circle2"></div>
<div class="circle3"></div>
<dic class="left-line"></dic>
<div class="right-line"></div>
</div>
<div class="left-hand">
<div class="left-hand-circle"></div>
</div>
<div class="right-hand">
<div class="right-hand-circle"></div>
</div>
<div class="footer">
<div class="left-footer"></div>
<div class="right-footer"></div>
</div>
</div>
</body>
</html>