Back to Carousel
Best Carousel

Best Carousel

#Best Carousel#Carousel

Live preview

Source code

html
<!-- Hero Split Carousel -->
<section class="container py-5">
  <div id="premiumHeroCarousel" class="carousel slide carousel-fade shadow-lg rounded-5 overflow-hidden" data-bs-ride="carousel">
    <!-- Progress Indicators -->
    <div class="carousel-indicators mb-4">
      <button type="button" data-bs-target="#premiumHeroCarousel" data-bs-slide-to="0" class="active rounded-pill" style="width: 30px; height: 6px;"></button>
      <button type="button" data-bs-target="#premiumHeroCarousel" data-bs-slide-to="1" class="rounded-pill" style="width: 30px; height: 6px;"></button>
      <button type="button" data-bs-target="#premiumHeroCarousel" data-bs-slide-to="2" class="rounded-pill" style="width: 30px; height: 6px;"></button>
    </div>

    <div class="carousel-inner">
      <!-- Slide 1: Modern Tech -->
      <div class="carousel-item active" data-bs-interval="5000">
        <div class="row g-0 vh-75 min-vh-500">
          <div class="col-lg-6 d-flex align-items-center bg-white p-5">
            <div class="px-md-4 animate-up">
              <span class="badge bg-primary-subtle text-primary px-3 py-2 rounded-pill mb-3 fw-bold">Innovation 2024</span>
              <h1 class="display-2 fw-black text-dark mb-4">Smart <span class="text-primary text-gradient">Solutions</span></h1>
              <p class="lead text-secondary mb-5">Experience the next generation of seamless living with our integrated AI ecosystem designed for your comfort.</p>
              <div class="d-flex flex-wrap gap-3">
                <a href="#" class="btn btn-primary btn-lg px-5 rounded-pill shadow-lg">Get Started</a>
                <a href="#" class="btn btn-outline-dark btn-lg px-4 rounded-pill">Watch Video <i class="bi bi-play-circle ms-1"></i></a>
              </div>
            </div>
          </div>
          <div class="col-lg-6 position-relative overflow-hidden card-img-zoom">
            <img src="https://images.unsplash.com/photo-1550745165-9bc0b252726f?auto=format&fit=crop&q=80&w=1200" class="w-100 h-100 object-fit-cover" alt="Modern Tech">
          </div>
        </div>
      </div>

      <!-- Slide 2: Design Focused -->
      <div class="carousel-item" data-bs-interval="5000">
        <div class="row g-0 vh-75 min-vh-500">
          <div class="col-lg-6 d-flex align-items-center bg-dark text-white p-5">
            <div class="px-md-4">
              <h1 class="display-2 fw-black mb-4">Ultra <span class="text-info">Minimal</span></h1>
              <p class="lead opacity-75 mb-5">Minimalist design meets maximum performance. Beautifully crafted hardware that fits perfectly into your lifestyle.</p>
              <a href="#" class="btn btn-info text-white btn-lg px-5 rounded-pill shadow">Explore Design</a>
            </div>
          </div>
          <div class="col-lg-6 position-relative overflow-hidden card-img-zoom">
            <img src="https://images.unsplash.com/photo-1494438639946-1ebd1d20bf85?auto=format&fit=crop&q=80&w=1200" class="w-100 h-100 object-fit-cover" alt="Design Focused">
          </div>
        </div>
      </div>

      <!-- Slide 3: Performance -->
      <div class="carousel-item" data-bs-interval="5000">
        <div class="row g-0 vh-75 min-vh-500">
          <div class="col-lg-6 d-flex align-items-center bg-light p-5">
            <div class="px-md-4">
              <h1 class="display-2 fw-black text-dark mb-4">Elite <span class="text-danger">Power</span></h1>
              <p class="lead text-secondary mb-5">Unmatched processing speeds for creators, developers, and visionaries built on robust architecture.</p>
              <button class="btn btn-danger btn-lg px-5 rounded-pill shadow">Try Beta Now</button>
            </div>
          </div>
          <div class="col-lg-6 position-relative overflow-hidden card-img-zoom">
            <img src="https://images.unsplash.com/photo-1593642702821-c8da6771f0c6?auto=format&fit=crop&q=80&w=1200" class="w-100 h-100 object-fit-cover" alt="Performance">
          </div>
        </div>
      </div>
    </div>

    <!-- Float Nav Controls -->
    <button class="carousel-control-prev w-auto ms-4" type="button" data-bs-target="#premiumHeroCarousel" data-bs-slide="prev">
      <span class="carousel-control-prev-icon bg-white text-dark shadow rounded-circle p-4 border" aria-hidden="true" style="filter: invert(1);"></span>
    </button>
    <button class="carousel-control-next w-auto me-4" type="button" data-bs-target="#premiumHeroCarousel" data-bs-slide="next">
      <span class="carousel-control-next-icon bg-white text-dark shadow rounded-circle p-4 border" aria-hidden="true" style="filter: invert(1);"></span>
    </button>
  </div>
</section>

<style>
  /* Custom Typography */
  .fw-black {
    font-weight: 900;
    letter-spacing: -2px;
  }

  .text-gradient {
    background: linear-gradient(45deg, #0d6efd, #0dcaf0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
  }

  /* Container Sizing */
  .vh-75 {
    height: 75vh;
  }

  .min-vh-500 {
    min-height: 550px;
  }

  /* Animations */
  .carousel-item.active .animate-up {
    animation: heroUp 1s cubic-bezier(0.23, 1, 0.32, 1) forwards;
  }

  .carousel-item.active .card-img-zoom img {
    animation: imgZoom 6s linear infinite alternate;
  }

  @keyframes heroUp {
    from {
      opacity: 0;
      transform: translateY(40px);
    }

    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  @keyframes imgZoom {
    from {
      transform: scale(1);
    }

    to {
      transform: scale(1.1);
    }
  }

  /* Slick Controls */
  .carousel-control-prev-icon,
  .carousel-control-next-icon {
    background-size: 40%;
    transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  }

  .carousel-control-prev:hover .carousel-control-prev-icon,
  .carousel-control-next:hover .carousel-control-next-icon {
    transform: scale(1.2);
    background-color: #0d6efd !important;
    filter: invert(0) !important;
    border-color: #0d6efd !important;
  }

  /* Indicators Styling */
  .carousel-indicators .active {
    background-color: #0d6efd;
  }

  /* Mobile Compatibility */
  @media (max-width: 991px) {
    .vh-75 {
      height: auto;
    }

    .col-lg-6 {
      text-align: center;
    }

    .d-flex {
      justify-content: center;
    }

    .display-2 {
      font-size: 3rem;
    }

    .min-vh-500 {
      min-height: auto;
    }

    .carousel-control-prev,
    .carousel-control-next {
      display: none;
    }
  }

</style>
How to use this best carousel

Add it to your project in three steps

  1. Copy the HTML from the Source code tab above and paste it inside your <div class="container"> wrapper.
  2. Make sure the Bootstrap 5 CDN CSS and JS are linked in your <head> and before </body>. Any CodeShikhi component assumes Bootstrap 5.3+ is already loaded.
  3. Swap the placeholder text, links, and images for your own content — the layout, spacing, and responsive behaviour stay intact.

The Best Carousel block is fully responsive and works on every screen from 320 px phones to 1440 px+ desktops without additional CSS.

Accessibility checklist

Ship it accessible by default

  • Use semantic HTML landmarks — <header>, <nav>, <main>, <footer> — so screen readers can navigate your page.
  • Give every image an alt attribute (empty alt="" if it's decorative).
  • Label icon-only buttons with aria-label and keep focus outlines visible.
  • Maintain a contrast ratio of at least 4.5:1 for body text against its background.
  • Test the best carousel with Tab / Shift+Tab and Enter — every interactive element should be reachable.
Step-by-step customisation

Make it match your brand

  1. Change the colour palette by overriding Bootstrap CSS variables: --bs-primary, --bs-body-bg.
  2. Adjust spacing with utility classes such as py-5, gap-4, and mt-lg-5 — no custom CSS required.
  3. Swap the typography by loading a Google Font in your <head> and setting --bs-body-font-family.
  4. Replace stock images with brand assets. Keep dimensions similar to avoid layout shift.
  5. Preview at multiple breakpoints (mobile, tablet, desktop) and tweak column spans if content wraps awkwardly.

Need the full theory? Read our Bootstrap 5 Technical Introduction Guide for grid, breakpoints, and Sass customisation in depth.

About the Best Carousel best carousel

This best carousel is part of the free CodeShikhi (কোড শিখি) Bootstrap 5 library — a growing collection of copy-paste website building blocks curated for learners and freelance developers. Every block is written in clean, semantic HTML with Bootstrap utility classes, keeps custom CSS to the minimum needed, and works without any build step. Use it as a starting point and adapt the markup, colours, and content to fit your project's brand and audience.

If you spot a bug, want a new variation, or would like to contribute an improvement, reach us via the contact page — we ship updates weekly based on community feedback.

Detailed Technical Breakdown

Detailed Technical Breakdown: Best Carousel

Browser compatibility & standards

The Best Carousel best carousel is authored against Bootstrap 5.3, which drops legacy Internet Explorer support and targets modern evergreen engines — Chrome, Edge, Firefox, Safari, and all Chromium-based mobile browsers. Because the markup relies exclusively on the standard CSS features that ship with Bootstrap (Flexbox, CSS Grid, CSS custom properties, and the responsive breakpoint system), you can safely deploy this best carousel to any browser released in the last five years without polyfills. If you need to support very old WebKit or Samsung Internet builds, load the standard Bootstrap 5 CSS from the official jsDelivr CDN — the bundled autoprefixer output already covers those vendor prefixes.

Performance impact

Performance-wise this block is intentionally light. The HTML payload for a typical Bootstrap best carousel is under 4 KB gzipped, and it shares the same Bootstrap CSS/JS bundle you are already loading — meaning the marginal cost of adding it to a page is effectively zero KB on repeat visits. There is no JavaScript framework runtime, no hydration cost, and no client-side data fetching. The only images referenced are placeholders you will replace with your own assets; when you do, serve them as WebP or AVIF, add explicit width and height attributes to prevent layout shift (CLS), and lazy-load anything below the fold with loading="lazy". These small changes typically move Lighthouse Performance scores from the mid-80s into the 95+ range on both mobile and desktop.

Utility classes used

The best carousel leans on Bootstrap's utility-first classes to stay declarative: spacing utilities (p-*, m-*, gap-*), the flex helpers (d-flex, align-items-*, justify-content-*), the grid system (container, row, col-lg-*), typography helpers (display-*, lead, text-*), and colour utilities that resolve to Bootstrap CSS variables such as --bs-primary, --bs-body-bg, and --bs-border-color. Because everything is expressed as utilities you can re-theme the entire best carousel by overriding a handful of CSS variables at the :root level — no Sass recompile required.

Exact customisation steps

  1. Copy the source HTML from the tab above and paste it inside your <body>. The outer <div class="container"> wrapper is already included so the best carousel sits on the Bootstrap grid.
  2. Replace the placeholder headings and paragraphs with your own copy. Keep heading levels in order (h1h2h3) so screen readers and search engines can parse the document outline.
  3. Swap any <img> tags for your brand assets. Match the original aspect ratio to avoid layout shift, and always fill in a meaningful alt attribute.
  4. Retune the palette by overriding CSS variables::root { --bs-primary: #4f46e5; --bs-body-bg: #ffffff; }. All utility colour classes update automatically.
  5. Test at each Bootstrap breakpoint — sm (576 px), md (768 px),lg (992 px), xl (1200 px), xxl (1400 px) — using your browser's device toolbar, and tweak column spans if long content wraps.
  6. Ship it with the standard Bootstrap 5 CDN in the <head> and the JS bundle before the closing </body>. No build step required.
Technical & Performance Integration Guide

Technical & Performance Integration Guide — Best Carousel (gallery)

When and why to use this gallery

An image gallery is the heaviest block you can put on a page, and also the one visitors judge fastest. The goal is a grid that stays perfectly aligned while loading progressively, so the layout never jumps as photographs arrive.

Accessibility & ARIA attributes

Give each image a descriptive alt attribute that says what the photo shows, not "image1.jpg". Purely decorative tiles take alt="". If clicking a thumbnail opens a lightbox, that dialog needs role="dialog", aria-modal="true", a focus trap and Escape-to-close — Bootstrap's modal component provides all of this when you keep its data attributes intact. Announce the gallery itself with a <section aria-label="Photo gallery"> wrapper.

Performance notes for this pattern

Always pair loading="lazy" with a fixed aspect ratio (.ratio.ratio-4x3) so lazy images reserve their space and CLS stays at zero. Serve responsive sources with srcset and sizes so phones download roughly 400 px-wide files rather than desktop originals — typically a 70–80% byte saving. Decode off the main thread with decoding="async", and keep the first row eager so the gallery paints something immediately.

Three customisation tricks

  • Use .object-fit-cover with a ratio wrapper for a masonry-like look without a JavaScript layout library.
  • Add .g-2 instead of .g-4 for a tighter, more editorial mosaic.
  • Preload only the first visible image with <link rel="preload" as="image">.

Mistakes to avoid

  • Shipping 3000 px originals to mobile.
  • Empty or duplicated alt text across every tile, which search engines treat as a quality signal.

More designs in this section