HTML+CSS實現太極旋轉效果

*陌顏*發表於2020-12-25

實現太極程式碼

<!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>
        .box {
            width: 400px;
            height: 400px;
            border: 2px solid black;
            border-radius: 50%;
            margin: auto;
            position: relative;
             /*呼叫動畫軌跡*/
             /* animation: name duration timing-function delay iteration-count       direction fill-mode; 
            animation : 動畫名稱 動畫所需的時間 動畫的運動方式(linear:勻速) 動畫的延遲時間 動畫的運動次數(number|infinite:無限次) */
            animation: taijimove 4s linear infinite;
        }

        .left_semicircle {
            width: 200px;
            height: 400px;
            background-color: black;
            border-radius: 400px 0px 0px 400px;
            position: absolute;
            left: 0px;
            top: 0px;
        }

        .right_semicircle {
            width: 200px;
            height: 400px;
            background-color: white;
            border-radius: 0px 400px 400px 0px;
            position: absolute;
            left: 200px;
            top: 0px;
        }

        .left_middle_circle {
            width: 200px;
            height: 200px;
            background-color: white;
            border-radius: 50%;
            position: absolute;
            left: 100px;
            bottom: 0px;
            z-index: 1;
        }

        .right_middle_circle {
            width: 200px;
            height: 200px;
            background-color: black;
            border-radius: 50%;
            position: absolute;
            left: -100px;
            top: 0px;
            z-index: 1;
        }

        .left_small_circle {
            width: 40px;
            height: 40px;
            background-color: black;
            border-radius: 50%;
            position: absolute;
            left: 80px;
            bottom: 80px;

        }

        .right_small_circle {
            width: 40px;
            height: 40px;
            background-color: white;
            border-radius: 50%;
            position: absolute;
            left: 80px;
            top: 80px;
        }
           /* 制動動畫軌跡 */
        @keyframes taijimove {
            0% {
                transform: rotate(0deg);
            }

            100% {
                transform: rotate(360deg);
            }
        }
    </style>
</head>

<body>
    <div class="box">
        <div class="left_semicircle">
            <div class="left_middle_circle">
                <div class="left_small_circle"></div>
            </div>
        </div>
        <div class="right_semicircle">
            <div class="right_middle_circle">
                <div class="right_small_circle"></div>
            </div>
        </div>
    </div>
</body>

</html>

在這裡插入圖片描述

相關文章