web前端中我们可以使用CSS去绘制各种形状的八卦图,我们既可以通过Canvas来进行绘制,也可以使用Css来进行绘制,今天给大家带来的就是使用Css来进行图形的绘制,这里我们使用了SetTImeOut来对样式进行了一个动画的显示,看上去特别的亮眼,下面就是关于这个星图的源码了:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>web前端绘制八卦图_超简单教程</title> <style id="style"> *{ margin: 0; padding: 0; } body{ background: #f1f1f1; } #box{ position: relative; width: 310px; height: 160px; margin: -160px auto 0; background: #fff; border-width: 150px 0 0 0;transition: .7s; } #box:before{ content: ""; position: absolute; top: -75px; left: 0; width: 15px; height: 15px; transition: .7s; } #box:after{ content: ""; position: absolute; top: -75px; right: 0; width: 15px; height: 15px; transition: .7s; } </style> </head> <body> <div id="box"></div> <script> var oStyle = document.getElementById('style'); var oBox = document.getElementById('box'); var timer = setTimeout(function(){ oBox.style.cssText += 'margin-top:50px;'; setTimeout(function(){ oBox.style.cssText += 'border-style:solid;border-color:#000;'; setTimeout(function(){ oBox.style.cssText += 'border-radius:50%;'; setTimeout(function(){ oStyle.innerHTML += '#box:before{background:#000;border:70px solid #fff;}'; setTimeout(function(){ oStyle.innerHTML += '#box:before{border-radius:50%;}'; setTimeout(function(){ oStyle.innerHTML += '#box:after{background:#fff;border:70px solid #000;}'; setTimeout(function(){ oStyle.innerHTML += '#box:after{border-radius:50%;}'; setTimeout(function(){ oStyle.innerHTML += '#box{animation: autoplay 2s infinite linear;}@keyframes autoplay{ form{ transform: rotate(0deg) } to{ transform: rotate(360deg) } }'; },500); },500); },500); },500); },1000); },1000); },1000); },1000); </script> </body> </html> |
这个是太极阴阳鱼,不是八卦图。
没咋研究,emmm