<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Modern Dynamic Page</title>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Inter', sans-serif;
}
:root {
--primary: #4361ee;
--secondary: #3f37c9;
--light: #f8f9fa;
--dark: #212529;
--gray: #6c757d;
}
body {
line-height: 1.6;
color: var(--dark);
background-color: var(--light);
}
/* Header & Navigation */
header {
position: fixed;
width: 100%;
background: transparent;
padding: 1.5rem 0;
transition: all 0.3s ease;
z-index: 1000;
}
header.scrolled {
background: white;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
padding: 1rem 0;
}
nav {
max-width: 1200px;
margin: 0 auto;
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 2rem;
}
.logo {
font-size: 1.5rem;
font-weight: 700;
color: var(--primary);
}
.nav-links {
display: flex;
gap: 2rem;
}
.nav-links a {
text-decoration: none;
color: var(--dark);
font-weight: 500;
transition: color 0.3s ease;
}
.nav-links a:hover {
color: var(--primary);
}
/* Hero Section */
.hero {
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
text-align: center;
padding: 0 2rem;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
}
.hero-content h1 {
font-size: 3.5rem;
margin-bottom: 1rem;
opacity: 0;
transform: translateY(30px);
animation: fadeUp 1s ease forwards 0.2s;
}
.hero-content p {
font-size: 1.2rem;
margin-bottom: 2rem;
opacity: 0;
transform: translateY(30px);
animation: fadeUp 1s ease forwards 0.4s;
}
.btn {
display: inline-block;
padding: 0.8rem 2rem;
background: white;
color: var(--primary);
border-radius: 50px;
text-decoration: none;
font-weight: 600;
transition: all 0.3s ease;
border: none;
cursor: pointer;
font-size: 1rem;
opacity: 0;
transform: translateY(30px);
animation: fadeUp 1s ease forwards 0.6s;
}
.btn:hover {
transform: translateY(-3px);
box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}
/* Features Section */
.features {
padding: 6rem 2rem;
max-width: 1200px;
margin: 0 auto;
}
.section-title {
text-align: center;
font-size: 2.5rem;
margin-bottom: 4rem;
color: var(--dark);
opacity: 0;
transform: translateY(30px);
transition: opacity 0.8s ease, transform 0.8s ease;
}
.section-title.show {
opacity: 1;
transform: translateY(0);
}
.features-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 2rem;
}
.feature-card {
background: white;
padding: 2.5rem;
border-radius: 10px;
box-shadow: 0 5px 15px rgba(0,0,0,0.05);
transition: all 0.3s ease;
opacity: 0;
transform: translateY(30px);
transition: opacity 0.8s ease, transform 0.8s ease;
}
.feature-card.show {
opacity: 1;
transform: translateY(0);
}
.feature-card:hover {
transform: translateY(-10px);
box-shadow: 0 15px 30px rgba(0,0,0,0.1);
}
.feature-card h3 {
font-size: 1.5rem;
margin-bottom: 1rem;
color: var(--primary);
}
/* Counter Section */
.counter-section {
background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
padding: 6rem 2rem;
text-align: center;
color: white;
}
.counter-container {
max-width: 600px;
margin: 0 auto;
}
.counter-value {
font-size: 4rem;
font-weight: 700;
margin: 2rem 0;
opacity: 0;
transform: scale(0.8);
transition: opacity 0.8s ease, transform 0.8s ease;
}
.counter-value.show {
opacity: 1;
transform: scale(1);
}
.counter-btn {
background: white;
color: #f5576c;
font-size: 1.2rem;
}
/* Footer */
footer {
background: var(--dark);
color: white;
text-align: center;
padding: 2rem;
}
/* Animations */
@keyframes fadeUp {
to {
opacity: 1;
transform: translateY(0);
}
}
/* Responsive Design */
@media (max-width: 768px) {
.hero-content h1 {
font-size: 2.5rem;
}
.nav-links {
display: none;
}
.features-grid {
grid-template-columns: 1fr;
}
}
</style>
</head>
<body>
<!-- Header -->
<header id="header">
<nav>
<div class="logo">DynamicPage</div>
<div class="nav-links">
<a href="#home">Home</a>
<a href="#features">Features</a>
<a href="#counter">Counter</a>
</div>
</nav>
</header>
<!-- Hero Section -->
<section class="hero" id="home">
<div class="hero-content">
<h1>Modern Dynamic Web Experience</h1>
<p>Beautiful, responsive, and interactive page with smooth animations and clean design</p>
<a href="#features" class="btn">Explore Features</a>
</div>
</section>
<!-- Features Section -->
<section class="features" id="features">
<h2 class="section-title">Our Features</h2>
<div class="features-grid">
<div class="feature-card">
<h3>Smooth Animations</h3>
<p>Enjoy fluid transitions and fade-in effects as you scroll through the page, creating an engaging user experience.</p>
</div>
<div class="feature-card">
<h3>Responsive Design</h3>
<p>Fully adaptive to all devices - from desktop to mobile, ensuring perfect viewing everywhere.</p>
</div>
<div class="feature-card">
<h3>Interactive Elements</h3>
<p>Clickable buttons, animated cards, and dynamic counter to make your browsing experience interactive.</p>
</div>
</div>
</section>
<!-- Counter Section -->
<section class="counter-section" id="counter">
<div class="counter-container">
<h2>Interactive Counter</h2>
<div class="counter-value" id="counterValue">0</div>
<button class="btn counter-btn" id="counterBtn">Click Me!</button>
</div>
</section>
<!-- Footer -->
<footer>
<p>© 2024 DynamicPage. All rights reserved.</p>
</footer>
<script>
// Header scroll effect
window.addEventListener('scroll', function() {
const header = document.getElementById('header');
header.classList.toggle('scrolled', window.scrollY > 50);
});
// Scroll reveal animation
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -50px 0px'
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('show');
}
});
}, observerOptions);
// Observe elements
document.querySelectorAll('.section-title, .feature-card, .counter-value').forEach(el => {
observer.observe(el);
});
// Smooth scrolling for nav links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function(e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
target.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
});
});
// Counter functionality
let counter = 0;
const counterValue = document.getElementById('counterValue');
const counterBtn = document.getElementById('counterBtn');
counterBtn.addEventListener('click', () => {
counter++;
counterValue.textContent = counter;
// Add pulse animation
counterValue.style.transform = 'scale(1.2)';
setTimeout(() => {
counterValue.style.transform = 'scale(1)';
}, 200);
});
</script>
</body>
</html>

作者声明:本文包含人工智能生成内容。