【CSS】用CSS画太极图

效果预览: https://sevlt.github.io/tai-chi/index.html

HTML:

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
        <title>Tai-chi</title>
        <link rel="stylesheet" href="style.css">
	</head>
	<body>
		<div id="yinyang"></div>
</html>

CSS:

body {
	background-color: #adadad;/*设置背景色*/
}

#yinyang {
	width: 200px;
	height: 200px;
	border-radius: 50%;
	background: linear-gradient(/*圆球上半部分为白色,下半部分为黑色*/
		to bottom,
		#ffffff 0%,
		#ffffff 50%,
		#000000 50%,
		#000000 100%
	);
	position: relative;
	margin: 100px auto;
}

#yinyang::before {
	position: absolute;
	content: "";
	width: 20px;
	height: 20px;
	border-radius: 50%;
	border: 40px solid black;/*左侧黑球套白点*/
	background-color: white;
	left: 0;
	top: 50px;
}

#yinyang::after {
	position: absolute;
	content: "";
	width: 20px;
	height: 20px;
	border-radius: 50%;
	border: 40px solid white;/*右侧白球套黑点*/
	background-color: black;
	right: 0;
	top: 50px;
}

效果图:

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章