【前端学习笔记 CSS系列二十三】多边形

一、效果

在这里插入图片描述

二、代码

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			#wubian {
				margin: 100px auto;
				width: 54px;
				height: 0px;
				border-top: 50px solid red;
				border-left: 18px solid transparent;
				border-right: 18px solid transparent;
				position: relative;
			}
			#wubian::before {
				content: '';
				position: absolute;
				height: 0px;
				width: 0px;
				border-bottom: 35px solid red ;
				border-left: 45px solid transparent ;
				border-right: 45px solid transparent ;  
				/* 左右两边的值决定了三角形的宽度 */
				top: -85px;
				left: -18px;
				
			}
			#liubian {
				margin: 150px auto;
				width: 100px;
				height: 55px;
				background-color: pink;
				position: relative;
			}
			#liubian::before {
				content: '';
				height: 0px;
				width: 0px;
				border-bottom: 15px solid pink;
				border-left: 50px solid transparent;
				border-right: 50px solid transparent;
				position: absolute;
				top: -15px;
			}
			#liubian::after {
				content: '';
				height: 0px;
				width: 0px;
				border-top: 15px solid pink;
				border-left: 50px solid transparent;
				border-right: 50px solid transparent;
				position: absolute;
				bottom: -15px;
				
			}
			#egg {
				width: 126px;
				height: 180px;
				background-color: #FA3;
				margin: 100px auto;
				border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
				/* 斜杠前是x轴上的四个角的,斜杠后是y轴上四个角 */
			}
			#taiji {
				background-color: #ccc;
			}
			#tj {
				width: 300px;
				height: 300px;
				margin: 20px auto;
				border-radius:50% ;
				background-color: #fff;
				border-left: 150px solid black;
				box-sizing: border-box;
				position: relative;
			}
			#tj::before {
				content: '';
				width: 40px;
				height: 40px;
				border-radius: 50%;
				background-color: #fff;
				position: absolute;
				left: -75px;
				border: 55px solid black;
			}
			#tj::after {
				content: '';
				width: 40px;
				height: 40px;
				border-radius: 50%;
				background-color: black;
				position: absolute;
				left: -75px;
				bottom: 0px;
				border: 55px solid white;
			}
			
		</style>
	</head>
	<body>
		<div id="wubian"></div>
		<div id="liubian">
			
		</div>
		<div id="egg">
			
		</div>
		<div id="taiji">
			<div id="tj">
				
			</div>
		</div>
	</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值