您好,欢迎来到客趣旅游网。
搜索
您的当前位置:首页纯css实现三等分饼图

纯css实现三等分饼图

来源:客趣旅游网

实现原理,先绘制一个圆,然后把圆分成两份,在绘制一个菱形,最下面的角是120°,这样就可以实现三等分啦

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>纯css实现三等分饼图</title>
		<style>
			.border {
				display: flex;
				border: solid;
				width: 50rem;
				height: 50rem;
				overflow: hidden;
				border-radius: 50%;
				position: relative;
				flex-wrap: wrap;
			}

			.box1 {
				display: inline-block;
				width: 100%;
				height: 100%;
				background-color: rgba(1, 1, 1, .5);
				margin-top: -15%;
				margin-left: 2%;
				clip-path: polygon(24rem 36rem, 48rem 18rem, 24rem 0, 0 18rem);
				z-index: 1;
			}

			.box2 {
				display: inline-block;
				width: 50%;
				height: 100%;
				background-color: pink;
				position: absolute;
			}

			.box3 {
				display: inline-block;
				width: 50%;
				height: 100%;
				background-color: lightskyblue;
				position: absolute;
				right: 0;
			}
		</style>
	</head>
	<body>
		<div class="border">
			<div class="box1"></div>
			<div class="box2"></div>
			<div class="box3"></div>
		</div>
		<script type="text/javascript" src="js/jquery-2.1.4.min.js"></script>
		<script>
			$('.box1').click(() => {
				alert(1)
			})
			$('.box2').click(() => {
				alert(2)
			})
			$('.box3').click(() => {
				alert(3)
			})
		</script>
	</body>

</html>

以上代码引入一下jquery后可以直接使用噢  

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- kqyc.cn 版权所有 赣ICP备2024042808号-2

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务