Creating an interactive landing page
The user wants an interactive landing page featuring parallax effects using only vanilla CSS and JavaScript. This involves providing a complete code example in HTML, CSS, and JS with a brief explanation. I'll make sure the design is minimal, incorporating layers for background, midground, and foreground, with mousemove and scroll-based parallax effects, plus interactive elements like a CTA button. It’s crucial to ensure accessibility, so I'll include alt text and good contrast while embedding CSS and JS inline for simplicity.Outlining interactive webpage features
I’m planning an interactive landing page with several features. It’ll have a fullscreen hero section with a parallax background, showcasing layers like gradients or images, mountains, clouds, and foreground text. I want to implement mouse move parallax, so the layers shift when moving the cursor, and a scrolling parallax effect for different background rates. I'll add interactive navigation with smooth scrolling and a CTA button. The HTML structure would include essential elements like a header, navigation, and sections for content.Defining CSS for the landing page
I'm laying out the CSS for the landing page. First, I’ll start with a reset and set the body margin to zero with a specific font, background, and color. The hero section will take up the full viewport height. For the parallax effect, I'll create layers using absolute positioning, ensuring they cover the entire area and are responsive to pointer events.
For backgrounds, I might use CSS gradients for the back and mid layers. I’m considering using shapes or simple gradients to keep things offline-friendly for demonstration, so I’ll prepare ready-to-use gradient examples.Implementing parallax effects
For the parallax demonstration, even plain colored rectangles could work, but adding shapes will enhance the visual appeal. I can use a radial gradient for backgrounds, but I'll comment to remind the user they can replace these with images.
In JavaScript, I’ll set up an event listener for when the DOM content is loaded. For the mouse move parallax, as the user moves the mouse, I'll calculate the cursor position and adjust the layer positions based on their depth. I'll make sure to consider both mouse movement and scroll effects for a comprehensive parallax experience.Finalizing parallax implementation
I'm focusing on the typical pattern for computing transformations where I combine mouse and scroll contributions. I will maintain the state for mouse position and scroll values, ensuring updates happen smoothly with requestAnimationFrame to avoid any jank.
I’ll set up the layers' transformation based on both scroll and mouse movement. I also want to add a simple fade-in effect for the hero content and smooth scrolling for the navigation links. To make it more interactive, I’m planning to add features like hoverable cards. Finally, I’ll provide a single HTML file with a concise explanation for easy customization. Below is a complete, minimal example of an interactive landing page with parallax effects created using only HTML, CSS, and vanilla JavaScript.
You can paste it into an index.html file and open it directly in a browser.
Full Example (single HTML file)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Parallax Landing Page</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<style>
/* Basic Reset */
*, *::before, *::after {
box-sizing: border-box;
margin: 0;
padding: 0;
}
html, body {
height: 100%;
scroll-behavior: smooth;
}
body {
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
Roboto, sans-serif;
color: #f5f7fb;
background-color: #050816;
line-height: 1.6;
}
a {
color: inherit;
text-decoration: none;
}
/* ---------- NAV ---------- */
.nav {
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 100;
display: flex;
align-items: center;
justify-content: space-between;
padding: 1rem 4vw;
backdrop-filter: blur(12px);
background: linear-gradient(to bottom,
rgba(5, 8, 22, 0.9),
rgba(5, 8, 22, 0)
);
border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.nav-logo {
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
font-size: 0.9rem;
}
.nav-links {
list-style: none;
display: flex;
gap: 1.5rem;
font-size: 0.9rem;
}
.nav-links a {
position: relative;
padding-bottom: 0.1rem;
}
.nav-links a::after {
content: "";
position: absolute;
left: 0;
bottom: 0;
height: 2px;
width: 0;
background: linear-gradient(90deg, #00f5a0, #00d9f5);
transition: width 0.25s ease;
}
.nav-links a:hover::after {
width: 100%;
}
/* ---------- HERO / PARALLAX ---------- */
.hero {
position: relative;
height: 100vh;
overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
padding: 0 4vw;
color: #f5f7fb;
}
.hero::before {
/* Subtle radial glow behind content */
content: "";
position: absolute;
width: 120%;
height: 120%;
left: -10%;
top: -10%;
background:
radial-gradient(circle at 20% -10%, rgba(0, 245, 160, 0.35), transparent 55%),
radial-gradient(circle at 80% 110%, rgba(0, 217, 245, 0.25), transparent 55%);
z-index: 0;
pointer-events: none;
}
.parallax-scene {
position: absolute;
inset: 0;
overflow: hidden;
pointer-events: none;
z-index: 0;
}
.layer {
position: absolute;
inset: -10%;
will-change: transform;
transition: transform 0.1s linear;
}
.layer--back {
background:
radial-gradient(circle at 10% 10%, #1a2a6c 0, transparent 50%),
radial-gradient(circle at 90% 15%, #b21f1f 0, transparent 55%),
radial-gradient(circle at 50% 90%, #fdbb2d 0, transparent 60%),
#050816;
filter: saturate(1.1);
z-index: 1;
}
.layer--mid {
background-image:
radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.15) 0, transparent 55%),
radial-gradient(circle at 80% 40%, rgba(255, 255, 255, 0.08) 0, transparent 60%),
radial-gradient(circle at 60% 80%, rgba(0, 217, 245, 0.18) 0, transparent 65%);
mix-blend-mode: screen;
z-index: 2;
opacity: 0.75;
}
.layer--front {
background-image:
radial-gradient(circle at 10% 80%, rgba(0, 245, 160, 0.4) 0, transparent 45%),
radial-gradient(circle at 85% 20%, rgba(0, 217, 245, 0.55) 0, transparent 55%);
z-index: 3;
opacity: 0.85;
}
.hero-content {
position: relative;
z-index: 10;
max-width: 720px;
text-align: center;
}
.hero-eyebrow {
letter-spacing: 0.25em;
text-transform: uppercase;
font-size: 0.75rem;
color: #9aa4c6;
margin-bottom: 0.75rem;
}
.hero-title {
font-size: clamp(2.6rem, 5vw, 3.6rem);
line-height: 1.1;
margin-bottom: 1rem;
}
.hero-title span {
background: linear-gradient(90deg, #00f5a0, #00d9f5, #a855f7);
-webkit-background-clip: text;
background-clip: text;
color: transparent;
}
.hero-subtitle {
max-width: 580px;
margin: 0 auto 2.2rem;
color: #c7cce2;
font-size: 0.98rem;
}
.hero-actions {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 1rem;
}
.btn-primary,
.btn-ghost {
border-radius: 999px;
padding: 0.85rem 1.7rem;
font-size: 0.95rem;
border: 1px solid transparent;
cursor: pointer;
transition:
transform 0.15s ease,
box-shadow 0.15s ease,
background 0.15s ease,
border-color 0.15s ease,
color 0.15s ease;
display: inline-flex;
align-items: center;
gap: 0.35rem;
text-decoration: none;
}
.btn-primary {
background: linear-gradient(120deg, #00f5a0, #00d9f5);
color: #050816;
box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
}
.btn-primary:hover {
transform: translateY(-1px) scale(1.02);
box-shadow: 0 22px 60px rgba(0, 0, 0, 0.7);
}
.btn-ghost {
background: rgba(5, 8, 22, 0.8);
border-color: rgba(255, 255, 255, 0.18);
color: #f5f7fb;
}
.btn-ghost:hover {
transform: translateY(-1px);
background: rgba(12, 20, 63, 0.95);
border-color: rgba(255, 255, 255, 0.35);
}
/* ---------- MAIN SECTIONS ---------- */
main {
background: radial-gradient(circle at top, #18182f 0, #050816 60%);
}
section {
padding: 5rem 4vw;
max-width: 1024px;
margin: 0 auto;
}
section:nth-of-type(2n) {
background: radial-gradient(circle at top, rgba(255, 255, 255, 0.02), transparent 70%);
border-radius: 32px;
margin-top: 4rem;
margin-bottom: 4rem;
}
.section-title {
font-size: 1.6rem;
margin-bottom: 1.5rem;
}
.section-lead {
color: #c7cce2;
max-width: 620px;
margin-bottom: 2.5rem;
font-size: 0.98rem;
}
.feature-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
gap: 1.5rem;
}
.feature-card {
position: relative;
padding: 1.6rem 1.4rem;
border-radius: 20px;
background: radial-gradient(circle at top left, rgba(0, 245, 160, 0.12), rgba(5, 8, 22, 0.98));
border: 1px solid rgba(255, 255, 255, 0.08);
box-shadow: 0 20px 45px rgba(0, 0, 0, 0.5);
overflow: hidden;
transition:
transform 0.2s ease,
box-shadow 0.2s ease,
border-color 0.2s ease,
background-position 0.2s ease;
cursor: pointer;
}
.feature-card::before {
content: "";
position: absolute;
inset: -40%;
background:
radial-gradient(circle at 0 0, rgba(0, 245, 160, 0.24), transparent 60%),
radial-gradient(circle at 100% 100%, rgba(0, 217, 245, 0.18), transparent 65%);
mix-blend-mode: screen;
opacity: 0;
transition: opacity 0.2s ease;
pointer-events: none;
}
.feature-card:hover {
transform: translateY(-4px) translateZ(0);
box-shadow: 0 26px 70px rgba(0, 0, 0, 0.7);
border-color: rgba(0, 245, 160, 0.4);
}
.feature-card:hover::before {
opacity: 1;
}
.feature-tag {
font-size: 0.75rem;
text-transform: uppercase;
letter-spacing: 0.18em;
color: #9aa4c6;
margin-bottom: 0.5rem;
}
.feature-title {
font-size: 1.05rem;
margin-bottom: 0.4rem;
}
.feature-text {
color: #c7cce2;
font-size: 0.9rem;
max-width: 30rem;
}
/* ---------- CTA / FOOTER ---------- */
.cta-box {
text-align: center;
padding: 3rem 1.5rem;
border-radius: 24px;
background: radial-gradient(circle at top, rgba(0, 245, 160, 0.24), rgba(5, 8, 22, 0.98));
border: 1px solid rgba(0, 245, 160, 0.3);
box-shadow: 0 24px 70px rgba(0, 0, 0, 0.65);
}
.cta-box h2 {
font-size: 1.6rem;
margin-bottom: 0.75rem;
}
.cta-box p {
color: #c7cce2;
max-width: 520px;
margin: 0 auto 1.8rem;
font-size: 0.95rem;
}
footer {
padding: 2rem 4vw 2.5rem;
border-top: 1px solid rgba(255, 255, 255, 0.08);
text-align: center;
color: #7c84a2;
font-size: 0.8rem;
background: #050816;
}
/* ---------- RESPONSIVE ---------- */
@media (max-width: 768px) {
.nav {
padding-inline: 1.5rem;
}
section {
padding-inline: 1.5rem;
}
.nav-links {
gap: 1rem;
font-size: 0.8rem;
}
.hero-subtitle {
font-size: 0.9rem;
}
.feature-card {
padding: 1.4rem 1.2rem;
}
}
</style>
</head>
<body>
<!-- NAVBAR -->
<header class="nav">
<div class="nav-logo">PARALLAX LAB</div>
<ul class="nav-links">
<li><a href="#about">About</a></li>
<li><a href="#features">Features</a></li>
<li><a href="#cta">Get Started</a></li>
</ul>
</header>
<!-- HERO WITH PARALLAX -->
<section class="hero" aria-label="Landing hero with parallax background">
<div class="parallax-scene" aria-hidden="true">
<div class="layer layer--back" data-depth="0.15"></div>
<div class="layer layer--mid" data-depth="0.35"></div>
<div class="layer layer--front" data-depth="0.7"></div>
</div>
<div class="hero-content">
<p class="hero-eyebrow">Experience depth</p>
<h1 class="hero-title">
Create immersive
<span>parallax landing pages</span>
with pure CSS & JavaScript.
</h1>
<p class="hero-subtitle">
Combine smooth scroll-based and mouse-based parallax to guide attention,
highlight key content, and make your product feel alive—without any
external libraries.
</p>
<div class="hero-actions">
<a href="#cta" class="btn-primary">
Get started now
</a>
<a href="#features" class="btn-ghost">
See how it works
</a>
</div>
</div>
</section>
<!-- MAIN CONTENT -->
<main>
<section id="about" aria-labelledby="about-title">
<h2 id="about-title" class="section-title">What is parallax scrolling?</h2>
<p class="section-lead">
Parallax scrolling is a technique where background elements move at a
slower rate than foreground elements as the user scrolls or moves the
cursor. This subtle separation of layers creates depth and a sense of
motion, making your page feel more dynamic and engaging.
</p>
<p class="section-lead">
The example on this page uses only semantic HTML, modern CSS, and a
small amount of vanilla JavaScript to animate layers based on both
scroll position and pointer movement.
</p>
</section>
<section id="features" aria-labelledby="features-title">
<h2 id="features-title" class="section-title">What this demo includes</h2>
<p class="section-lead">
You can use this structure as a starter for your own landing page.
Swap gradients for images, adjust motion depth, and connect it to your
content and brand.
</p>
<div class="feature-grid">
<article class="feature-card">
<p class="feature-tag">01 · Scroll parallax</p>
<h3 class="feature-title">Layers that move at different speeds</h3>
<p class="feature-text">
As you scroll, each background layer shifts vertically at a unique
rate using CSS transforms. Foreground elements stay crisp while the
background slowly drifts, creating subtle depth.
</p>
</article>
<article class="feature-card">
<p class="feature-tag">02 · Pointer parallax</p>
<h3 class="feature-title">Interactive cursor-driven motion</h3>
<p class="feature-text">
Move your mouse (or trackpad) across the hero section. Layers react
to your movement, slightly tilting the scene for an interactive,
game-like feeling.
</p>
</article>
<article class="feature-card">
<p class="feature-tag">03 · Vanilla stack</p>
<h3 class="feature-title">No dependencies required</h3>
<p class="feature-text">
No frameworks, no plugins. Just semantic HTML, modern CSS
(including gradients and blur effects), and a few lines of efficient,
requestAnimationFrame-based JavaScript.
</p>
</article>
</div>
</section>
<section id="cta" aria-labelledby="cta-title">
<div class="cta-box">
<h2 id="cta-title">Start from this template</h2>
<p>
Copy this file, plug in your brand, replace gradients with imagery,
and tune the parallax depth values. In a few minutes, you can ship a
modern, interactive landing page that stands out.
</p>
<div class="hero-actions" style="justify-content: center;">
<a href="#top" class="btn-primary">Back to top</a>
<a href="#features" class="btn-ghost">Explore features again</a>
</div>
</div>
</section>
</main>
<footer>
Built with vanilla HTML, CSS & JS · Parallax demo
</footer>
<!-- PARALLAX SCRIPT -->
<script>
(function () {
const layers = document.querySelectorAll(".layer");
const hero = document.querySelector(".hero");
let mouseX = window.innerWidth / 2;
let mouseY = window.innerHeight / 2;
let scrollY = window.scrollY || window.pageYOffset;
let ticking = false;
function updateLayers() {
const w = window.innerWidth;
const h = window.innerHeight;
const relX = (mouseX - w / 2) / (w / 2); // -1 .. 1
const relY = (mouseY - h / 2) / (h / 2); // -1 .. 1
layers.forEach(layer => {
const depth = parseFloat(layer.dataset.depth) || 0;
const moveX = -relX * depth * 30; // pointer parallax (X)
const moveY = -relY * depth * 30; // pointer parallax (Y)
const scrollOffset = scrollY * depth * 0.35; // scroll parallax (Y)
const totalY = moveY - scrollOffset;
layer.style.transform =
`translate3d(${moveX}px, ${totalY}px, 0)`;
});
ticking = false;
}
function requestTick() {
if (!ticking) {
requestAnimationFrame(updateLayers);
ticking = true;
}
}
// Mouse / pointer movement inside the hero
hero.addEventListener("mousemove", (e) => {
mouseX = e.clientX;
mouseY = e.clientY;
requestTick();
});
// For touch devices: approximate parallax on scroll only.
window.addEventListener("scroll", () => {
scrollY = window.scrollY || window.pageYOffset;
requestTick();
});
// Initial paint
requestTick();
// Keep center updated on resize
window.addEventListener("resize", () => {
mouseX = window.innerWidth / 2;
mouseY = window.innerHeight / 2;
requestTick();
});
})();
</script>
</body>
</html>
How to customize
If you tell me your brand style (colors, imagery, or product), I can adapt this template specifically for your use case.