CSS3创意精美页面过渡动画效果

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>CSS3 Creative Page Transition Animation</title>

<style>

* {

margin: 0;

padding: 0;

box-sizing: border-box;

}

body {

font-family: 'Arial', sans-serif;

background: #f5f5f5;

color: #333;

overflow-x: hidden;

}

.page-container {

position: relative;

width: 100%;

height: 100vh;

overflow: hidden;

}

.page {

position: absolute;

width: 100%;

height: 100%;

display: flex;

flex-direction: column;

justify-content: center;

align-items: center;

padding: 20px;

transition: transform 1s ease-in-out;

background: #fff;

box-shadow: 0 0 20px rgba(0,0,0,0.1);

}

.page h1 {

font-size: 3rem;

margin-bottom: 20px;

color: #3498db;

}

.page p {

font-size: 1.2rem;

max-width: 600px;

text-align: center;

margin-bottom: 30px;

line-height: 1.6;

}

.btn {

padding: 12px 30px;

background: #3498db;

color: white;

border: none;

border-radius: 30px;

font-size: 1rem;

cursor: pointer;

transition: all 0.3s ease;

text-decoration: none;

box-shadow: 0 4px 6px rgba(0,0,0,0.1);

}

.btn:hover {

background: #2980b9;

transform: translateY(-3px);

box-shadow: 0 6px 8px rgba(0,0,0,0.15);

}

/* Page transition animations */

.page:nth-child(1) {

z-index: 3;

transform: translateX(0);

}

.page:nth-child(2) {

z-index: 2;

transform: translateX(100%);

background: #f1c40f;

}

.page:nth-child(3) {

z-index: 1;

transform: translateX(200%);

background: #2ecc71;

}

/* Animation classes */

.slide-out {

transform: translateX(-100%) rotateY(30deg) scale(0.9);

opacity: 0.8;

}

.slide-in {

transform: translateX(0) rotateY(0) scale(1);

}

.slide-next {

transform: translateX(100%) rotateY(-30deg) scale(0.9);

opacity: 0.8;

}

/* Shape animations */

.shape {

position: absolute;

opacity: 0.1;

z-index: 0;

}

.circle {

width: 200px;

height: 200px;

border-radius: 50%;

background: #3498db;

animation: float 8s infinite ease-in-out;

}

.triangle {

width: 0;

height: 0;

border-left: 100px solid transparent;

border-right: 100px solid transparent;

border-bottom: 173px solid #e74c3c;

animation: float 10s infinite ease-in-out reverse;

}

.square {

width: 150px;

height: 150px;

background: #9b59b6;

animation: float 12s infinite ease-in-out;

}

@keyframes float {

0%, 100% {

transform: translateY(0) rotate(0deg);

}

50% {

transform: translateY(-50px) rotate(10deg);

}

}

</style>

</head>

<body>

<div class="page-container">

<!-- Shapes for background animation -->

<div class="shape circle" style="top: 20%; left: 10%;"></div>

<div class="shape triangle" style="top: 60%; left: 80%;"></div>

<div class="shape square" style="top: 30%; left: 70%;"></div>

<div class="shape circle" style="top: 70%; left: 20%; width: 100px; height: 100px;"></div>

<!-- Page 1 -->

<div class="page" id="page1">

<h1>Welcome</h1>

<p>Experience this beautiful CSS3 page transition animation. Click the button below to see the magic happen!</p>

<a href="#" class="btn" onclick="nextPage()">Next Page</a>

<!-- Inserted URL as requested -->

</div>

<!-- Page 2 -->

<div class="page" id="page2">

<h1>Amazing Effects</h1>

<p>This transition uses CSS3 transforms and animations to create a smooth, visually appealing experience between pages.</p>

<a href="#" class="btn" onclick="nextPage()">Next Page</a>

</div>

<!-- Page 3 -->

<div class="page" id="page3">

<h1>All Done!</h1>

<p>You've seen all the pages in this demo. Click the button to start over and see the animations again.</p>

<a href="#" class="btn" onclick="resetPages()">Start Over</a>

</div>

</div>

<script>

let currentPage = 1;

const totalPages = 3;

function nextPage() {

if (currentPage >= totalPages) return;

const current = document.getElementById(`page${currentPage}`);

const next = document.getElementById(`page${currentPage + 1}`);

current.classList.add('slide-out');

next.classList.add('slide-in');

if (currentPage + 2 <= totalPages) {

const nextNext = document.getElementById(`page${currentPage + 2}`);

nextNext.classList.add('slide-next');

}

currentPage++;

}

function resetPages() {

currentPage = 1;

// Reset all pages to original positions

for (let i = 1; i <= totalPages; i++) {

const page = document.getElementById(`page${i}`);

page.classList.remove('slide-out', 'slide-in', 'slide-next');

if (i === 1) {

page.style.transform = 'translateX(0)';

} else if (i === 2) {

page.style.transform = 'translateX(100%)';

} else {

page.style.transform = 'translateX(200%)';

}

}

}

</script>

</body>

</html>

相关推荐
唐璜Taro5 分钟前
Vue3 + TypeScript 后台管理系统完整方案
前端·javascript·typescript
dustcell.13 分钟前
haproxy七层代理
java·开发语言·前端
掘金酱25 分钟前
「寻找年味」 沸点活动|获奖名单公示🎊
前端·人工智能·后端
患得患失94935 分钟前
【前端】前端动画优化的核心
前端
Xin_z_37 分钟前
Vue3 + Sticky 锚点跳转被遮挡问题解决方案
前端·javascript·vue.js
REDcker43 分钟前
WebCodecs VideoDecoder 的 hardwareAcceleration 使用
前端·音视频·实时音视频·直播·webcodecs·videodecoder
修炼前端秘籍的小帅1 小时前
Stitch——Google热门的免费AI UI设计工具
前端·人工智能·ui
精神状态良好1 小时前
实战:从零构建本地 Code Review 插件
前端·llm
荒诞英雄1 小时前
Vue3 Teleport我真是没招了
前端·vue.js
YAY_tyy1 小时前
2025 最新版 Node.js 下载安装及环境配置教程
前端·node.js·教程·工具配置