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-imageon.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-accentand--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
dpath of.ph-ridgeto draw a different skyline, or delete the SVG for a straight edge. - Remove
.ph-bandif 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.