Skip to content

Background Image Slideshow

Bootstrap 5 hero section whose background cross-fades through photos with a slow zoom, progress dots, captions and a pause button.

Also known as: hero background slideshow, fullscreen image slider hero, background image cross fade, hero section with image carousel, photo slideshow hero

Background Image Slideshow live demo

Open in new tab

Bootstrap 5 code (HTML, CSS, JS)

A Bootstrap 5 hero section whose background cycles through full-bleed photos with a soft cross-fade and a slow zoom, while the headline and buttons stay in place. A bottom bar shows the photo caption, progress dots and a pause button. Use it for travel, hospitality, real estate or event landing pages.

How it works

The root is section.bis-hero. The photos are img.bis-slide elements stacked inside the absolutely positioned .bis-slides layer, cropped with object-fit: cover. Only the slide with is-active is visible; it fades in through an opacity transition and runs the bis-zoom keyframes, a slow scale from 1 to --bis-zoom. The ::after pseudo-element of .bis-slides adds the dark gradient from --bis-overlay so the white text stays readable on any photo.

The content sits in .bis-content: the .bis-copy block with eyebrow, title, lead text and two buttons, and the .bis-bar with .bis-caption, the .bis-dot buttons and the .bis-toggle button.

The timing is driven by CSS. The .bis-dot-fill bar of the active dot runs the bis-progress animation for the length of --bis-interval. The script listens for its animationend event and calls go() with the next index. go() moves is-active to the new slide, gives the old one is-leaving so it keeps its zoom while fading out, marks earlier dots with is-done, moves aria-current and updates the caption from the slide's data-caption. Because the timer is an animation, pausing is just animation-play-state: paused: is-paused comes from the pause button, and is-held is set while the pointer or keyboard focus is in the bar or the browser tab is hidden. Without JavaScript the first photo stays visible.

Customization

  • data-interval on .bis-hero: time per photo in milliseconds, e.g. 5000 for a faster slideshow.
  • --bis-fade in .bis-hero: length of the cross-fade between photos.
  • --bis-zoom in .bis-hero: strength of the zoom; set it to 1 for a static background.
  • --bis-overlay in .bis-hero: change or lighten the gradient over the photos.
  • --bis-accent in .bis-hero: recolor the primary button, eyebrow text and the running progress bar.
  • Add an img.bis-slide with a data-caption and a matching .bis-dot button to include another photo.
  • min-height in .bis-hero: make the section taller or shorter.

Use cases

  • Travel agencies: a headline stays fixed while destination photos fade and slowly zoom behind it
  • Hotels and hospitality: show rooms and views with a caption and progress dots in the bottom bar
  • Real estate sites: cycle through property photos behind a call-to-action
  • Event landing pages: a pause button lets visitors stop the moving background
  • Resorts and outdoor brands: a dark gradient keeps white text readable on any photo

Accessibility

The photos are decorative (alt=""); their descriptions are in the dot labels such as "Photo 2: Wooden dock on a calm lake". The dots are buttons inside a labelled role="group", with aria-current on the visible photo. The pause button switches its aria-label between "Pause slideshow" and "Play slideshow". Under prefers-reduced-motion: reduce the zoom is disabled, the fade becomes instant and the slideshow starts paused. All controls have a visible focus outline.

Usage notes

Requires Bootstrap 5 and Bootstrap Icons. The photos come from Unsplash; replace them with your own images at roughly 1600 × 1000 pixels. Several sections can be used on one page; each runs its own timer.

Background Image Slideshow at a glance

Framework
Bootstrap 5
Code
HTML, CSS, JavaScript
JavaScript
Vanilla JavaScript, no jQuery
Dependencies
Bootstrap 5, Bootstrap Icons
Layout
Responsive, works on mobile, dark design
Category
Backgrounds
License
Free for personal and commercial use

Questions about this template

Can I use the Background Image Slideshow 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?

Load Bootstrap 5 and Bootstrap Icons from a CDN (the links are under Requirements). Paste the HTML where the component should appear, add the CSS to your stylesheet and load the JavaScript before the closing </body> tag. Download HTML gives you a complete page with everything already linked.

Does it need jQuery or a JavaScript framework?

No. The script is plain vanilla JavaScript, so it works without jQuery, React or Vue. You can still use the markup inside those frameworks.

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

Add these to your page (already included in the download):

  • <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
  • <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
  • <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
Background Image Slideshow – Bootstrap 5 backgrounds component screenshot
Background Image Slideshow · Bootstrap 5 Backgrounds

More Backgrounds

Animated Blob Background – Pure CSS backgrounds preview

Animated Blob Background

Pure CSS animated background with blurred, morphing color blobs drifting behind a hero headline, with a pause button and reduced-motion support.

CSS Pattern Backgrounds – Pure CSS backgrounds preview

CSS Pattern Backgrounds

Eight pure CSS gradient background patterns (dots, polka, grid, graph paper, stripes, crosshatch, checkerboard, zigzag) with a live scale slider.

Animated Gradient Background – Pure CSS backgrounds preview

Animated Gradient Background

Pure CSS hero section with a slowly shifting multi-color gradient, drifting blurred blobs and a grain overlay, customizable through CSS variables.