使用伪元素,border-radius, 绘制安卓机器人

<!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>

 

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值