硬币旋转动画css

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>硬币旋转动画</title>
    <style>
        .rotate-wrap {
            width: 100px;
            height: 100px;
            margin: 100px;
            background-color: yellow;
            transform-style: preserve-3d;
            animation: rotate 5s linear infinite;
            position: relative;
        }
        .rotate-wrap:hover {
            animation-play-state: paused;
        }
        .rotate-wrap .front, .rotate-wrap .reverse{
            width: 100px;
            height: 100px;
            background-size: cover;
        }
        .rotate-wrap .front{
            position: absolute;
            top: 0;
            left: 0;
            bottom: 0;
            right: 0;
            background-image: url('https://picsum.photos/id/935/100/100');
        }
        .rotate-wrap .reverse{
            background-image: url('https://picsum.photos/id/835/100/100');
        }

        .circle{
            border-radius: 50%;
        }
        .line{
            height: 200px;
            width: 1px;
            position:absolute;
            top: 0;
            left: 50%;
            background: red;
            transform: translateZ(0px);
        }

        @keyframes rotate {
            0%{
                transform: rotateY(0deg) ;
            }
            100% {
                transform: rotateY(360deg);
            }
        }
    </style>
</head>
<body>
<div class="rotate-wrap">
    <div class="front circle" style="transform: translateZ(1px);"></div>
    <div class="reverse circle"></div>
</div>

<div class="rotate-wrap">
    <div class="line"></div>
    <div class="front" style="transform: translateZ(5px);"></div>
    <div class="reverse" style="transform: translateZ(-5px);"></div>
</div>

</body>
</html>

猜你喜欢

转载自blog.csdn.net/weixin_39418338/article/details/119850880