Skip to content

Stats Section with Background Image

Bootstrap 5 stats section with four key numbers in glass cards over a darkened background photo, with a count-up animation on scroll.

Also known as: counter section, animated numbers section, key figures section, count up statistics

Stats Section with Background Image live demo

Open in new tab

Bootstrap 5 code (HTML, CSS, JS)

A Bootstrap 5 stats section that shows four key numbers in frosted glass cards on top of a darkened background photo. The numbers count up when the section scrolls into view. Use it on landing pages, about pages and company profiles to back up your claims with figures.

How it works

The root section.sbi-stats draws the photo with CSS: background-image stacks a dark linear-gradient overlay over the --sbi-image URL, and background-size: cover keeps it filling the section at any width. The overlay keeps white text readable on every part of the photo.

Inside a Bootstrap container, a first row places the kicker, the h2.sbi-heading and the .sbi-lead paragraph side by side on large screens. The numbers live in a ul.row with four col-6 col-lg-3 items, so you get a 2×2 grid on phones and a single row from the lg breakpoint. Every .sbi-stat card has a semi-transparent background, a thin border and backdrop-filter: blur(). It holds a .sbi-icon, the .sbi-value with the .sbi-num and an amber .sbi-suffix, and the .sbi-label.

The script runs on DOMContentLoaded for every .sbi-stats. It first adds a visually hidden copy of each final value for screen readers. Then it resets the numbers to zero and uses an IntersectionObserver to start a requestAnimationFrame count-up with an ease-out curve when 30% of the section is visible. Without JavaScript, or with reduced motion, the final values from the markup are shown straight away.

Customization

  • --sbi-image on .sbi-stats in style.css: replace the URL with your own background photo.
  • --sbi-overlay: make the overlay darker or lighter; keep enough contrast for the white text.
  • --sbi-accent: change the amber color of the kicker, icons and suffixes.
  • data-sbi-target on a .sbi-num: set the final number; keep the same value as the visible text so the no-JS fallback matches.
  • data-sbi-decimals: show decimals during the count-up, e.g. 2 for 99.98.
  • DURATION in script.js: make the count-up faster or slower (in milliseconds).
  • col-6 col-lg-3 on the list items: use col-lg-4 for three stats per row.

Use cases

  • Landing pages: four key numbers count up in glass cards when the section scrolls into view
  • About pages: figures over a darkened photo back up claims about the company
  • Company profiles: icons, suffixes and labels explain each statistic in a compact row
  • Agency sites: a full-width background image makes the numbers feel visual and trustworthy

Accessibility

The section is labelled by its h2 through aria-labelledby, and the stats are a real list. Icons are decorative and marked aria-hidden="true". Screen readers read the visually hidden final value instead of the animated digits, so they never hear intermediate numbers. The count-up is skipped entirely when prefers-reduced-motion: reduce is set. White text on the dark overlay keeps contrast well above WCAG AA.

Usage notes

The background photo comes from Unsplash and should be replaced with your own image. Requires Bootstrap 5.3 and Bootstrap Icons. Several sections on one page work independently because each one has its own observer.

Stats Section with Background Image 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
Stats Sections
License
Free for personal and commercial use

Questions about this template

Can I use the Stats Section 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?

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">
Stats Section with Background Image – free Bootstrap 5 stats section template
Stats Section with Background Image · free Bootstrap 5 stats section template

More Stats Sections

Stats with Circular Progress Rings – free Pure CSS stats section template

Stats with Circular Progress Rings

Dark stats section with four SVG circular progress rings that fill and count up to their percentage when scrolled into view.

Stats Section with Count-Up Numbers – free Tailwind CSS stats section template

Stats Section with Count-Up Numbers

Tailwind CSS key-metrics section on an emerald brand background with large numbers, labels, trend notes and an accessible count-up on scroll.

Stats Section with Four Key Numbers – free WordPress stats section template

Stats Section with Four Key Numbers

A dark stats section with four key numbers, labels and short notes, a statistics counter band for Gutenberg that highlights company figures.

Animated Number Counters – free Pure CSS stats section template

Animated Number Counters

Stats section with four number cards that count up when scrolled into view, using IntersectionObserver, locale formatting and reduced-motion support.