纯css实现太极八卦图

感觉最近好像闯鬼了,赶紧写个八卦图避避邪,开玩笑了,不废话,上菜,看效果上代码。
  • 效果
  • 代码,你们都是大佬,这里就不解释代码了 (hover会转动喔)。
html 复制代码
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>太极八卦图</title>
    <style>
      body {
        height: 100vh;
        display: flex;
        align-items: center;
        justify-content: center;
        background: #ddd;
        box-sizing: border-box;
        margin: 0;
        padding: 0;
      }
      .main {
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
      }
      .taijitu {
        position: relative;
        width: 200px;
        height: 200px;
        display: flex;
        background: linear-gradient(#000 50%, #fff 50%);
        border: 1px solid #000;
        border-radius: 50%;
        transform: rotate(90deg);
      }
      .taijitu::before,
      .taijitu::after {
        content: '';
        width: 30px;
        height: 30px;
        border-radius: 50%;
        border: 35px solid transparent;
      }
      .taijitu::before {
        position: absolute;
        left: 0;
        top: 50px;
        background: #000;
        border-color: #fff;
      }
      .taijitu::after {
        position: absolute;
        right: 0;
        top: 50px;
        background: #fff;
        border-color: #000;
      }
      .main:hover {
        transform: rotate(666turn);
        transition-delay: 1s;
        transition-property: all;
        transition-duration: 59s;
        transition-timing-function: cubic-bezier(0.34, 0, 0.84, 1);
      }
      .baguaBox {
        position: absolute;
        width: 128%;
      }
      .baguaBox .item {
        position: relative;
        display: flex;
        align-items: center;
        width: 100%;
      }
      .baguaBox > div:nth-child(2) {
        transform: rotate(-45deg);
      }
      .baguaBox > div:nth-child(3) {
        transform: rotate(-90deg);
      }
      .baguaBox > div:nth-child(4) {
        transform: rotate(-135deg);
      }

      .baguaBox > div:nth-child(1) div:first-child,
      .baguaBox > div:nth-child(2) div:first-child,
      .baguaBox > div:nth-child(3) div:first-child,
      .baguaBox > div:nth-child(4) div:first-child {
        transform: rotate(-90deg);
      }
      .baguaBox > div:nth-child(1) div:last-child,
      .baguaBox > div:nth-child(2) div:last-child,
      .baguaBox > div:nth-child(3) div:last-child,
      .baguaBox > div:nth-child(4) div:last-child {
        transform: rotate(90deg);
      }

      .item div {
        position: absolute;
      }
      .item div:first-child {
        left: 0;
      }
      .item div:last-child {
        right: 0;
      }
      .item div span {
        margin: auto;
        display: block;
        width: 30px;
        height: 1.5px;
        background: #000;
        margin-bottom: 5px;
      }
      .item div span:nth-child(2) {
        width: 20px;
      }
      .item div span:nth-child(3) {
        width: 10px;
      }
    </style>
  </head>
  <body>
    <div class="main">
      <!-- 太极图 -->
      <div class="taijitu"></div>
      <!-- 八卦 -->
      <div class="baguaBox">
        <div class="item">
          <div><span></span><span></span><span></span></div>
          <div><span></span><span></span><span></span></div>
        </div>
        <div class="item">
          <div><span></span><span></span><span></span></div>
          <div><span></span><span></span><span></span></div>
        </div>
        <div class="item">
          <div><span></span><span></span><span></span></div>
          <div><span></span><span></span><span></span></div>
        </div>
        <div class="item">
          <div><span></span><span></span><span></span></div>
          <div><span></span><span></span><span></span></div>
        </div>
      </div>
    </div>
  </body>
</html>
  • 观众老爷门记得点赞。
相关推荐
Amd79410 分钟前
Nuxt.js 应用中的 webpack:compiled 事件钩子
前端·webpack·开发·编译·nuxt.js·事件·钩子
生椰拿铁You19 分钟前
09 —— Webpack搭建开发环境
前端·webpack·node.js
狸克先生30 分钟前
如何用AI写小说(二):Gradio 超简单的网页前端交互
前端·人工智能·chatgpt·交互
baiduopenmap1 小时前
百度世界2024精选公开课:基于地图智能体的导航出行AI应用创新实践
前端·人工智能·百度地图
loooseFish1 小时前
小程序webview我爱死你了 小程序webview和H5通讯
前端
菜牙买菜1 小时前
让安卓也能玩出Element-Plus的表格效果
前端
请叫我欧皇i1 小时前
html本地离线引入vant和vue2(详细步骤)
开发语言·前端·javascript
533_1 小时前
[vue] 深拷贝 lodash cloneDeep
前端·javascript·vue.js
guokanglun1 小时前
空间数据存储格式GeoJSON
前端
zhang-zan2 小时前
nodejs操作selenium-webdriver
前端·javascript·selenium