CSS3 iPhone锁屏解锁动画特效

CSS3实现iPhone锁屏解锁动画特效

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CSS3 iPhone锁屏解锁动画特效</title>
    <style>
        body {
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            background-color: #000;
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
        }

        .lock-screen {
            position: relative;
            width: 320px;
            height: 568px;
            background-color: #000;
            border-radius: 30px;
            overflow: hidden;
            box-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
        }

        .time {
            position: absolute;
            top: 100px;
            left: 0;
            right: 0;
            text-align: center;
            color: #fff;
            font-size: 48px;
            font-weight: 200;
        }

        .date {
            position: absolute;
            top: 160px;
            left: 0;
            right: 0;
            text-align: center;
            color: #fff;
            font-size: 16px;
        }

        .slider-container {
            position: absolute;
            bottom: 100px;
            left: 0;
            right: 0;
            text-align: center;
        }

        .slider {
            width: 80px;
            height: 80px;
            background-color: rgba(255, 255, 255, 0.2);
            border-radius: 50%;
            margin: 0 auto;
            position: relative;
            cursor: pointer;
        }

        .slider::after {
            content: '';
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 30px;
            height: 30px;
            background-color: #fff;
            border-radius: 50%;
        }

        .slider-animation {
            animation: slide 1.5s ease-out forwards;
        }

        @keyframes slide {
            0% {
                transform: translateX(0);
            }
            50% {
                transform: translateX(120px);
            }
            100% {
                transform: translateX(0);
            }
        }

        .water-drop {
            position: absolute;
            bottom: 100px;
            left: 50%;
            transform: translateX(-50%);
            width: 80px;
            height: 80px;
            background-color: rgba(255, 255, 255, 0.2);
            border-radius: 50%;
            opacity: 0;
            animation: drop 1.5s ease-out forwards;
        }

        @keyframes drop {
            0% {
                transform: translateX(-50%) translateY(0);
                opacity: 0;
            }
            20% {
                opacity: 1;
            }
            80% {
                opacity: 1;
            }
            100% {
                transform: translateX(-50%) translateY(200px);
                opacity: 0;
            }
        }

        .website-link {
            position: absolute;
            bottom: 20px;
            left: 0;
            right: 0;
            text-align: center;
            color: rgba(255, 255, 255, 0.3);
            font-size: 12px;
        }
    </style>
</head>
<body>
    <div class="lock-screen">
        <div class="time">9:41</div>
        <div class="date">Monday, January 1</div>
        <div class="slider-container">
            <div class="slider" id="slider"></div>
            <div class="water-drop" id="water-drop"></div>
        </div>
        <div class="website-link">
        </div>
    </div>

    <script>
        const slider = document.getElementById('slider');
        const waterDrop = document.getElementById('water-drop');

        slider.addEventListener('click', () => {
            slider.classList.add('slider-animation');
            waterDrop.style.opacity = '1';
            waterDrop.style.animation = 'drop 1.5s ease-out forwards';

            setTimeout(() => {
                slider.classList.remove('slider-animation');
                waterDrop.style.opacity = '0';
                waterDrop.style.animation = '';
            }, 1500);
        });
    </script>
</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值