Skip to content

Parallax Hero with Background Image

Pure CSS hero section with a fixed mountain photo that creates a parallax scroll effect, a dark overlay, call-to-action buttons and stats.

Also known as: parallax scrolling hero, fixed background hero, hero with background photo, parallax header image, landing page hero banner

Parallax Hero with Background Image live demo

Open in new tab

Pure CSS code (HTML, CSS)

A full-width hero section with a parallax scroll effect, built with pure CSS and no JavaScript. A misty mountain photo stays fixed while the headline, buttons and a mountain-ridge divider scroll over it, which suits landing pages for travel, outdoor brands, events or portfolios.

How it works

The root .ph-wrap holds two sections. .ph-hero carries two background layers: the dark gradient from --ph-overlay and the photo from --ph-image. The photo layer uses background-attachment: fixed, so it is positioned against the viewport rather than the section. When the page scrolls, the section moves and the photo does not, creating the parallax depth without any scroll listeners or transforms.

Inside the hero, .ph-content contains the .ph-eyebrow label, the .ph-title heading with an .ph-accent highlight, the .ph-lead paragraph, .ph-actions with two buttons and the .ph-stats list. An inline SVG .ph-ridge sits at the bottom edge. It is filled with the same color as the following .ph-band, so the photo appears to dip behind a mountain silhouette. Because the ridge scrolls with the page while the photo stays fixed, the depth effect is stronger. The round .ph-scroll link jumps to #ph-routes, the .ph-band section with three .ph-item cards.

On phones the overlay is a uniform dark gradient so the text stays readable over the light sky. From 720px it becomes a directional gradient that is darkest behind the left-aligned text and lets the ridges show on the right.

Customization

  • --ph-image on .ph-wrap: swap the URL for your own photo. The photo comes from Unsplash, so replace it with your own image before going live.
  • --ph-overlay: change the gradient strength or tint. It is set twice, once for mobile and once in the 720px media query.
  • --ph-height: the hero height, clamp(34rem, 92vh, 52rem) by default.
  • --ph-accent and --ph-accent-ink: the peach color of the highlighted words, the primary button and the stat borders, and the text color on that button.
  • --ph-band-bg: the color of the section below. It also fills .ph-ridge, so both stay in sync.
  • Edit the d path of .ph-ridge to draw a different skyline, or delete the SVG for a straight edge.
  • Remove .ph-band if you only need the hero; the parallax still works with your own content below it.

Use cases

  • Travel and outdoor sites: a fixed mountain photo creates a parallax effect as visitors scroll
  • Landing pages: a dark overlay keeps headlines and call-to-action buttons readable
  • Brand homepages: stats under the headline back up the message
  • Portfolio sites: a full-width photo hero makes a strong first impression

Accessibility

The hero is a section labelled by its h1 through aria-labelledby, and the band is labelled by its h2. The overlay keeps white text above a 4.5:1 contrast ratio. Decorative SVGs use aria-hidden="true", and the scroll arrow has a visually hidden .ph-sr label. Buttons and the arrow get a white focus outline. With prefers-reduced-motion: reduce the background stops being fixed and the arrow animation is turned off.

Usage notes

iOS Safari ignores fixed backgrounds, so the (hover: none) media query switches touch devices to a normal background to avoid a zoomed, blurry photo. The heading is an h1; change it to h2 if the page already has one.

Parallax Hero with Background Image at a glance

Framework
Pure CSS
Code
HTML, CSS
JavaScript
Not needed, CSS only
Dependencies
None
Layout
Responsive, works on mobile, dark design
Category
Hero Sections
License
Free for personal and commercial use

Questions about this template

Can I use the Parallax Hero with Background Image code for free?

Yes. You can copy or download the code and use it in personal and commercial projects, including client work. No sign-up is needed. Reselling it as part of a component library or template collection is not allowed; see the license.

How do I add it to my website?

There is nothing to install. Paste the HTML where the component should appear and add the CSS to your stylesheet. Download HTML gives you a complete page with everything already linked.

Does it need jQuery or a JavaScript framework?

No. It is built with HTML and CSS only, so there is no JavaScript to load.

Does it work on mobile?

Yes. The layout adapts to small screens. Use the Mobile and Tablet buttons above the live demo to check it at phone and tablet width.

Requirements

No dependencies. Pure HTML, CSS and JavaScript.

Parallax Hero with Background Image – free Pure CSS hero section template
Parallax Hero with Background Image · free Pure CSS hero section template

More Hero Sections

Split Hero with Diagonal Photo Clip – free Pure CSS hero section template

Split Hero with Diagonal Photo Clip

Pure CSS split hero with headline, buttons and stats beside a full-height photo cut on a diagonal with clip-path, plus an accent stripe and rating badge.

Hero with Rotating Words – free Pure CSS hero section template

Hero with Rotating Words

Dark hero section whose headline cycles through words with a slide-and-fade animation, a pause button and decorative stat cards.

Split Hero with App Screenshot – free Tailwind CSS hero section template

Split Hero with App Screenshot

Dark Tailwind CSS split hero with gradient headline, two CTA buttons and an animated mock app dashboard built entirely from divs.

Dental Clinic Hero with Appointment Button – free WordPress hero section template

Dental Clinic Hero with Appointment Button

A dental clinic hero section with a booking button, a call button, three patient trust points and a rounded treatment room photo, built from core Gutenberg blocks.

Hero with Search Bar – free Bootstrap 6 hero section template

Hero with Search Bar

Bootstrap 6 directory hero on a photo background with a large pill search bar, a searchable area Combobox, popular search chips and category tiles.

Hero with Background Video Overlay – free Bootstrap 6 hero section template

Hero with Background Video Overlay

Full-width Bootstrap 6 hero with a muted background video or slow-zoom poster photo, dark gradient overlay, headline, two buttons, stats and a pause control.