Skip to content

Card with Image Overlay

Bootstrap 5 image cards with text overlaid on photos, a readability gradient, category badges, save buttons and a featured layout.

Also known as: image overlay cards, text over image cards, photo cards with gradient, featured story cards

Card with Image Overlay live demo

Open in new tab

Bootstrap 5 code (HTML, CSS, JS)

A set of Bootstrap 5 cards that place the title, meta line and category badge directly on top of a photo, with a dark gradient that keeps the text readable on any image. It suits blog and magazine home pages, travel journals, portfolio highlights and "featured stories" blocks.

How it works

The root is section.cio-section, which defines the palette and card height with CSS custom properties. Inside a Bootstrap row, one wide .cio-card--featured card takes half the row on large screens and two portrait cards share the other half; on tablets the small cards sit side by side and on phones everything stacks.

Each card is a Bootstrap card with a full-size card-img and a card-img-overlay. The image fills the card with object-fit: cover, and .cio-overlay turns the overlay into a flex column: the badge and save button at the top, .cio-body with the meta line and title at the bottom. The overlay background is a linear-gradient that goes from almost black at the bottom to nearly transparent at the top, so the photo stays visible while the text keeps strong contrast. The title link uses Bootstrap's stretched-link, making the whole card clickable. On hover or keyboard focus the card lifts and the image zooms slightly.

The script runs on DOMContentLoaded for every .cio-section. A click on .cio-save toggles aria-pressed, swaps the icon between bi-bookmark and bi-bookmark-fill, updates the button label and announces the change in the hidden .cio-status region. Without JavaScript the cards and links work; only the save buttons do nothing.

Customization

  • --cio-shade in .cio-section: sets the darkest gradient color; raise its alpha for brighter photos or lower it for darker ones.
  • --cio-height in .cio-section: changes the card height (24rem by default, 28rem from the lg breakpoint).
  • --cio-accent in .cio-section: recolors the kicker, the featured badge, the saved bookmark and the focus outline.
  • --cio-radius in .cio-section: use 0.5rem for sharper corners or 2rem for a softer look.
  • col-lg-6 and col-lg-3 on the columns: switch to col-lg-4 everywhere for three equal cards.
  • d-none d-sm-block on .cio-text: remove it to show the excerpt on phones too.
  • Replace the placehold.co URLs with your own photos and keep the alt text descriptive.

Use cases

  • Blog and magazine homepages: the title, meta line and category badge sit directly on top of each photo
  • Travel journals: a dark gradient keeps overlaid text readable over any destination image
  • Portfolio highlights: a larger featured card draws attention to the most important project
  • Featured stories blocks: save buttons on the cards let readers bookmark articles for later

Accessibility

Every image has meaningful alt text and each card is an article with an h3 title link. Because the whole card is a stretched-link, the outline is drawn on the card with :has() when the link has :focus-visible. The save buttons are real button elements with aria-pressed and an aria-label naming the story, and they sit above the stretched link through z-index. A visually hidden role="status" region announces saves. The gradient keeps white text above WCAG AA contrast, and the lift and zoom transitions are disabled under prefers-reduced-motion.

Usage notes

Requires Bootstrap 5 (loaded automatically) and Bootstrap Icons. Browsers without :has() still show a focus ring on the save buttons; add your own fallback outline if you need one on the card.

Card with Image Overlay 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
Category
Cards
License
Free for personal and commercial use

Questions about this template

Can I use the Card with Image Overlay 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">
Card with Image Overlay – free Bootstrap 5 card template
Card with Image Overlay · free Bootstrap 5 card template

More Cards

3D Flip Card – free Pure CSS card template

3D Flip Card

Three pure CSS 3D flip cards that turn on hover, keyboard focus or tap to reveal details and a link on the back.

Event Card with Photo and Date Badge – free Pure CSS card template

Event Card with Photo and Date Badge

Pure CSS event cards with a cover photo, ticket-stub date badge, category chip, time and venue details, price and a ticket button.

Cards with Hover Lift – free Pure CSS card template

Cards with Hover Lift

Pure CSS blog card grid where each card lifts with a deeper shadow and zooms its image on hover or keyboard focus.

Blog Post Card – free Tailwind CSS card template

Blog Post Card

Tailwind CSS blog post card with cover illustration, category badge, date, reading time, clamped excerpt, author row and a fully clickable area.

Card with Image Overlay Text – free Bootstrap 6 card template

Card with Image Overlay Text

Dark Bootstrap 6 travel cards with headline, place and price set over full-bleed photos, a gradient scrim for readability, save buttons and a Toast.

Glassmorphism Card – free Tailwind CSS card template

Glassmorphism Card

Frosted glass profile card in Tailwind CSS with backdrop blur, a light reflection and a follow button over colorful animated gradient blobs.