如何用动画实现开关门效果(未完成)

仅实现开门动画,关门动画未实现。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        section{
            width: 600px;
            height: 600px;
            background-color: pink;
            display: flex;
            position: relative;
            top: 200px;
            left: 40vw;
            perspective: 1200px;
            perspective-origin: center;
            transform-style: preserve-3d;
        }
        section .box1{
            width: 300px;
            height: 600px;
            border: 1px solid black;
            background-color: pink;
            animation: run1-1 3s linear 0s forwards;
            transform-origin: 0 0;
            
        }
        .box1:before{
            content: "";
            display: block;
            width: 18px;
            height: 18px;
            border: 1px solid black;
            border-radius: 50%;
            margin: 290px 0;
            margin-left: 270px;
        }
        section .box2{
            width: 300px;
            height: 600px;
            border: 1px solid black;
            background-color: pink;
            transform-origin: 100% 100%;
            
        }
        .box2:before{
            content: "";
            display: block;
            width: 18px;
            height: 18px;
            border: 1px solid black;
            border-radius: 50%;
            margin: 290px 0;
            margin-left: 10px;
        }
        img{
            width: 100%;
            height: 100%;
            position: absolute;
            z-index: -10;
            
        }

        section:hover .box1{           
            animation: run1 3s linear 0s forwards; 
        }
        section:hover .box2{
            animation: run2 3s linear 0s forwards; 
        }
        section:hover img{
            animation: run3 3s linear 3s forwards; 
        }
        @keyframes run1 {
            0%{
                transform-origin: 0 0;
                transform: rotateY(0);
            }
            100%{
                transform-origin: 0 0;
                transform: rotateY(-90deg);
            }
        }
        

        @keyframes run2 {
            0%{
                transform-origin: 100% 100%;
                transform: rotateY(0);
            }
            100%{
                transform-origin: 100% 100%;
                transform: rotateY(90deg);
            }
        }
        @keyframes run3 {
            0%{
                transform: translateZ(0px);
            }
            100%{
                transform: translateZ(500px);
            }
        }
    </style>
</head>
<body>
    <section>
        <div class="box1"></div>
        <div class="box2"></div>
        <img src="./image/R-C.gif" alt="">
    </section>
</body>
</html>

       

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值