APP页面转换动画

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>APP页面转换动画</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: 'Arial', sans-serif;
            background: #f5f5f5;
            overflow-x: hidden;
        }
        
        .app-container {
            width: 100%;
            max-width: 414px;
            height: 736px;
            margin: 20px auto;
            position: relative;
            overflow: hidden;
            box-shadow: 0 0 20px rgba(0,0,0,0.2);
            border-radius: 30px;
            background: #fff;
        }
        
        .page {
            position: absolute;
            width: 100%;
            height: 100%;
            padding: 20px;
            transition: transform 0.5s ease-in-out, opacity 0.5s ease-in-out;
            background: linear-gradient(135deg, #6e8efb, #a777e3);
            color: white;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            text-align: center;
        }
        
        .page h1 {
            font-size: 28px;
            margin-bottom: 20px;
            text-shadow: 1px 1px 3px rgba(0,0,0,0.3);
        }
        
        .page p {
            font-size: 16px;
            margin-bottom: 30px;
            line-height: 1.6;
        }
        
        .btn {
            padding: 12px 30px;
            background: white;
            color: #6e8efb;
            border: none;
            border-radius: 25px;
            font-size: 16px;
            font-weight: bold;
            cursor: pointer;
            box-shadow: 0 4px 8px rgba(0,0,0,0.1);
            transition: all 0.3s ease;
        }
        
        .btn:hover {
            transform: translateY(-3px);
            box-shadow: 0 6px 12px rgba(0,0,0,0.15);
        }
        
        .page-1 {
            z-index: 10;
        }
        
        .page-2 {
            transform: translateX(100%);
            opacity: 0;
            z-index: 5;
            background: linear-gradient(135deg, #f093fb, #f5576c);
        }
        
        .page-3 {
            transform: translateX(100%);
            opacity: 0;
            z-index: 1;
            background: linear-gradient(135deg, #43e97b, #38f9d7);
        }
        
        /* 动画效果 */
        .slide-out {
            animation: slideOut 0.5s forwards;
        }
        
        .slide-in {
            animation: slideIn 0.5s forwards;
        }
        
        @keyframes slideOut {
            0% {
                transform: translateX(0);
                opacity: 1;
            }
            100% {
                transform: translateX(-100%);
                opacity: 0;
            }
        }
        
        @keyframes slideIn {
            0% {
                transform: translateX(100%);
                opacity: 0;
            }
            100% {
                transform: translateX(0);
                opacity: 1;
            }
        }
        
        /* 其他动画效果 */
        .fade-out {
            animation: fadeOut 0.5s forwards;
        }
        
        .fade-in {
            animation: fadeIn 0.5s forwards;
        }
        
        @keyframes fadeOut {
            0% {
                opacity: 1;
            }
            100% {
                opacity: 0;
            }
        }
        
        @keyframes fadeIn {
            0% {
                opacity: 0;
            }
            100% {
                opacity: 1;
            }
        }
        
        .rotate-out {
            animation: rotateOut 0.5s forwards;
        }
        
        .rotate-in {
            animation: rotateIn 0.5s forwards;
        }
        
        @keyframes rotateOut {
            0% {
                transform: rotateY(0deg);
                opacity: 1;
            }
            100% {
                transform: rotateY(90deg);
                opacity: 0;
            }
        }
        
        @keyframes rotateIn {
            0% {
                transform: rotateY(-90deg);
                opacity: 0;
            }
            100% {
                transform: rotateY(0deg);
                opacity: 1;
            }
        }
        
        .logo {
            width: 100px;
            height: 100px;
            margin-bottom: 30px;
            background: rgba(255,255,255,0.2);
            border-radius: 20px;
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 40px;
        }
    </style>
</head>
<body>
    <div class="app-container">
        <div class="page page-1">
            <div class="logo">1</div>
            <h1>欢迎使用我们的APP</h1>
            <p>体验前所未有的流畅操作和精美界面设计</p>
            <button class="btn" onclick="nextPage('page-1', 'page-2', 'slide')">开始探索</button>
        </div>
        
        <div class="page page-2">
            <div class="logo">2</div>
            <h1>发现更多精彩功能</h1>
            <p>我们的APP提供了多种实用功能,满足您的各种需求</p>
            <button class="btn" onclick="nextPage('page-2', 'page-3', 'fade')">继续</button>
            <button class="btn" style="margin-top: 15px;" onclick="nextPage('page-2', 'page-1', 'rotate')">返回</button>
        </div>
        
        <div class="page page-3">
            <div class="logo">3</div>
            <h1>个性化设置</h1>
            <p>根据您的喜好定制专属界面和功能</p>
            <button class="btn" onclick="nextPage('page-3', 'page-2', 'fade')">返回</button>
            <p style="margin-top: 30px;">
                <a href="https://a.88a.org.cn/HOkL" style="color: white; text-decoration: underline;">了解更多信息</a>
            </p>
        </div>
    </div>

    <script>
        function nextPage(currentPageId, nextPageId, animationType) {
            const currentPage = document.querySelector(`.${currentPageId}`);
            const nextPage = document.querySelector(`.${nextPageId}`);
            
            // 根据选择的动画类型添加相应的类
            switch(animationType) {
                case 'slide':
                    currentPage.classList.add('slide-out');
                    nextPage.classList.add('slide-in');
                    break;
                case 'fade':
                    currentPage.classList.add('fade-out');
                    nextPage.classList.add('fade-in');
                    break;
                case 'rotate':
                    currentPage.classList.add('rotate-out');
                    nextPage.classList.add('rotate-in');
                    break;
                default:
                    currentPage.classList.add('slide-out');
                    nextPage.classList.add('slide-in');
            }
            
            // 动画结束后重置状态
            setTimeout(() => {
                currentPage.classList.remove('slide-out', 'fade-out', 'rotate-out');
                nextPage.classList.remove('slide-in', 'fade-in', 'rotate-in');
                
                // 重置所有页面的transform和opacity
                document.querySelectorAll('.page').forEach(page => {
                    if(page.classList.contains(nextPageId)) {
                        page.style.transform = 'translateX(0)';
                        page.style.opacity = '1';
                    } else {
                        page.style.transform = 'translateX(100%)';
                        page.style.opacity = '0';
                    }
                });
            }, 500);
        }
    </script>
</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值