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; }
效果圖: