【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;
}

效果圖:

 

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