<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>安卓机器人 的实现</title>
<style type="text/css">
* {
padding: 0;
margin: 0;
}
body {
background-color: #ccc;
}
.content {
width: 500px;
height: 500px;
border: 1px red solid;
margin: 50px auto;
}
.an_header {
width: 250px;
height: 125px;
background-color: darkgreen;
margin: 10px auto;
border-radius: 125px 125px 0px 0px;
position: relative;
}
/* 使用伪元素,添加左边眼睛:提取公共代码,再复写单独的某个样式 */
.an_header::before,
.an_header::after {
/* 1 设置content属性 */
content: "";
/* 2 如果需要设置宽度,就应该转换其为块级元素,它默认是行级元素float position block*/
position: absolute;
width: 20px;
height: 20px;
bottom: 40px;
border-radius: 10px;
background-color: #fff;
}
.an_header::before {
left: 70px;
}
.an_header::after {
right: 70px;
}
.an_body {
width: 250px;
height: 250px;
background-color: darkgreen;
border-radius: 0px 0px 20px 20px;
margin: 0px auto;
position: relative;
}
.an_body::before,
.an_body::after {
content: "";
position: absolute;
background-color: darkgreen;
width: 30px;
height: 180px;
border-radius: 10px;
top: 20px;
}
.an_body::before {
left: -40px;
/* 向左移动40px */
}
.an_body::after {
right: -40px;
}
.an_footer {
width: 250px;
height: 100px;
margin: 0px auto;
position: relative;
}
.an_footer::before,
.an_footer::after {
content: "";
position: absolute;
background-color: darkgreen;
width: 30px;
height: 90px;
border-radius: 0 0 10px 10px;
}
.an_footer::before {
left: 50px;
}
.an_footer::after {
right: 50px;
}
</style>
</head>
<body>
<div class="content">
<div class="an_header"></div>
<div class="an_body"></div>
<div class="an_footer"></div>
</div>
</body>
</html>