2018-09-04画太极

第一种方法:笨方法 不停画圆即可实现。

HTML部分

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
<div id="YinYang">
  <div class="one"></div>
  <div class="two"></div>
  <div class="three"></div>
  <div class="four"></div>
</div>
</body>
</html>

Css部分

body{
  background-color: #444;
}
#YinYang{
  width:200px;
  height: 200px;
  border: 1px solid black;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(255,255,255,1) 0%, rgba(255,255,255,1) 50%, rgba(0,0,0,1) 51%, rgba(0,0,0,1) 100%);
  position: relative;
  margin:100px auto;
}

#YinYang > .one{
   
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: black;
  position: absolute;
  top:50px;
}

#YinYang > .two {
  width:100px;
  height: 100px;
  background: white;
  position: absolute;
  top:50px;
  left:100px;
  border-radius: 50%;
  
}
#YinYang > .three  {
  border: 1px solid black;
  width:25px;
  height:25px;
  background: white;
  position: absolute;
  top:85px;
  border-radius:50%;
  left:35px;
  
}
#YinYang > .four{
  border: 1px solid black;
  width:25px;
  height:25px;
  background: black;
  position: absolute;
  top:85px;
  border-radius:50%;
  left:140px;
  
}

效果图:

太极.png

第二种方法:利用伪类 before 和 after 。

HTML

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>

<div id="YinYang">
 
</div>
</body>
</html>
#YinYang  {
    width: 96px;
    height: 48px;
    background: #eee;
    border-color: red;
    border-style: solid;
    border-width: 2px 2px 50px 2px;
    border-radius: 100%;
    position: relative;
}

#YinYang::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    background: #eee;
    border: 18px solid red;
    border-radius: 100%;
    width: 12px;
    height: 12px;
}

#YinYang::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    background: red;
    border: 18px solid #eee;
    border-radius:100%;
    width: 12px;
    height: 12px;
}
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 第一部分 HTML&CSS整理答案 1. 什么是HTML5? 答:HTML5是最新的HTML标准。 注意:讲述HT...
    kismetajun阅读 27,610评论 1 45
  • 概要 64学时 3.5学分 章节安排 电子商务网站概况 HTML5+CSS3 JavaScript Node 电子...
    阿啊阿吖丁阅读 9,285评论 0 3
  • 前端开发面试题 <a name='preface'>前言</a> 只看问题点这里 看全部问题和答案点这里 本文由我...
    自you是敏感词阅读 784评论 0 3
  • 青山碧,暮色合。夕阳影里,燕子低飞,寻觅旧家;黄昏光下,牧童吆牛,赶回温巢。微弱的煤油灯下,一位母亲,手心...
    北凉凤起阅读 467评论 0 0
  • 1, 2017年12月25日圣诞夜,西安交大博士杨宝德因不堪忍受其导师周教授的奴役,深感出国无望,学术无果,在浐河...
    鱼鱼爱吃饭阅读 314评论 0 0