招喚特效 Summoning Effect

招喚特效 Summoning Effect

by wllai2001

HTML

<div class="container">
        <div class="oval top">top</div>
        <div class="oval bottom">bottom</div>
    </div>

CSS

body, html {
    height: 100%;
    margin: 0;
    overflow: hidden;
}

.container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    position: relative;
    perspective: 1000px; /* 3D效果 */
}

.oval {
    width: 100px;
    height: 50px;
    background-color: #3498db;
    border: 2px dashed #000;
    border-radius: 50%;
    position: absolute;
    animation-duration: 4s;
    animation-timing-function: ease-in-out;
    animation-iteration-count: infinite;
    transform-style: preserve-3d; /* 3D效果 */
    
}

.top {
    animation-name: topAnimation;
    top: 100px; /* 上橢圓的位置 */
}

.bottom {
    animation-name: bottomAnimation;
    top: 300px; /* 下橢圓的位置 */
}

@keyframes topAnimation {
    0% {
        transform: translateZ(0) scaleY(0) scaleX(0);
    }
    10% {
        transform: translateZ(0) scaleY(1) scaleX(1);
    }
    90% {
        transform: translateZ(0) scaleY(1) scaleX(1);
    }
    100% {
        transform: translateZ(0) scaleY(0) scaleX(0);
    }
}

@keyframes bottomAnimation {
    0% {
        transform: translateZ(0) scaleY(0) scaleX(0);
    }
    10% {
        transform: translateZ(0) scaleY(1) scaleX(1);
    }
    90% {
        transform: translateZ(0) scaleY(1) scaleX(1);
    }
    100% {
        transform: translateZ(0) scaleY(0) scaleX(0);
    }
}