CSS动画中心环绕

HTML代码如下(示例):

 <main>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
    </main>

CSS代码如下(示例):

<style>
        main {
            width: 300px;
            height: 300px;
            transform: translate(50%, 50%);
            border-radius: 50%;
            position: relative;
            background-color: red;
        }
        
        div {
            width: 50px;
            height: 50px;
            background-color: red;
            border-radius: 0 50%/0 100% 100%;
            position: absolute;
            top: 0;
            left: 0;
            line-height: 200px;
            color: aqua;
            transition-duration: 1s;
            // 重点 旋转中心
            transform-origin: 150px 150px;
            transform: scale(0);
            transition: 2s;
        }
        
        div::after {
            content: "CSS";
        }
        
        main::after {
            content: '';
            width: 200px;
            height: 200px;
            color: red;
            border-radius: 50%;
        }
        // 360/9=40deg
        main:hover div:nth-child(1) {
            transform: scale(1) rotate(40deg);
        }
        
        main:hover div:nth-child(2) {
            transform: scale(1) rotate(80deg);
        }
        
        main:hover div:nth-child(3) {
            transform: scale(1) rotate(120deg);
        }
        
        main:hover div:nth-child(4) {
            transform: scale(1) rotate(160deg);
        }
        
        main:hover div:nth-child(5) {
            transform: scale(1) rotate(200deg);
        }
        
        main:hover div:nth-child(6) {
            transform: scale(1) rotate(240deg);
        }
        
        main:hover div:nth-child(7) {
            transform: scale(1) rotate(280deg);
        }
        
        main:hover div:nth-child(8) {
            transform: scale(1) rotate(320deg);
        }
        
        main:hover div:nth-child(9) {
            transform: scale(1) rotate(360deg);
        }
    </style>

原文:

https://blog.csdn.net/LiHang1234567777/article/details/125937514

本文链接: https://jianz.xyz/index.php/archives/392/

1 + 1 =
快来做第一个评论的人吧~