两种方式实现css三球围绕中心旋转问题

 

<!--
 * @Author: Simoon.jia
 * @Date: 2024-12-13 17:38:51
 * @LastEditors: Simoon.jia
 * @LastEditTime: 2024-12-13 19:00:34
 * @Description: 描述
-->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style lang="scss">
      body {
        width: 100vw;
        height: 100vh;
        overflow: hidden;
        background: #000;
        display: flex;
        align-items: center;
        justify-content: center;
      }
      /* .aaa {
             width: 400px;
             height: 400px;
             background-color: blueviolet;
             overflow: visible;
             position: relative;
             transform-origin: 50% 28.87%;
             animation: rotate 6s linear infinite;
           }
           .a {
             transform: translate(-50%, -50%);
             width: 50px;
             height: 50px;
             border-radius: 50%;
             background-color: cadetblue;
             position: absolute;
           }
           .a1 {
             left: 0px;
             top: 0;
           }
           .a2 {
             left: 400px;
             top: 0;
           }
           .a3 {
             left: 200px;
             top: 346.41px;
           }
           .a4 {
             transform: translate(-50%, -50%);
             width: 10px;
             height: 10px;
             background-color: yellowgreen;
             position: absolute;
             left: 50%;
             top: 28.87%;
           } */
      .aaa {
        width: 1px;
        height: 1px;
        background-color: blueviolet;
        overflow: visible;
        position: relative;
        transform-origin: 50% 50%;
        animation: rotate 6s linear infinite;
      }
      .a {
        transform: translate(-50%, -50%);
        width: 200px;
        height: 200px;
        border-radius: 50%;
        background-color: cadetblue;
        position: absolute;
        color: red;
      }
      .a1 {
        left: 0px;
        top: 0;
      }
      .a2 {
        left: 0px;
        top: 0;
      }
      .a3 {
        left: 0px;
        top: 0;
      }
      .a4 {
        transform: translate(-50%, -50%);
        width: 10px;
        height: 10px;
        /* background-color: yellowgreen; */
        position: absolute;
        left: 50%;
        top: 28.87%;
      }
      .b {
        width: 1px;
        height: 300px;
        background-color: blanchedalmond;
        transform-origin: 50% 100%;
        position: absolute;
        bottom: 0;
        rotate: 120deg;
      }
      .b1 {
        rotate: 120deg;
      }
      .b2 {
        rotate: 0deg;
      }
      .b3 {
        rotate: 240deg;
      }
      @keyframes rotate {
        from {
          transform: rotate(0deg);
        }
        to {
          transform: rotate(360deg);
        }
      }
    </style>
  </head>

  <body>
    <!-- <div class="aaa">
      <div class="a1 a"></div>
      <div class="a2 a"></div>
      <div class="a3 a"></div>

      <div class="a4"></div>
    </div> -->
    <div class="aaa">
      <div class="b1 b">
        <div class="a1 a"></div>
      </div>
      <div class="b2 b">
        <div class="a2 a"></div>
      </div>
      <div class="b3 b">
        <div class="a3 a"></div>
      </div>
      <!-- <div class="a4"></div> -->
    </div>
  </body>
</html>

 

posted @ 2024-12-16 09:55  SimoonJia  阅读(3)  评论(0编辑  收藏  举报