Close Menu

    Subscribe to Updates

    Get the latest creative news from FooBar about art, design and business.

    What's Hot

    How to make Happy birthday cake Animation using HTML & CSS

    29 May 2025

    How to create Toast Catcher Game using HTML CSS and JS

    26 May 2025

    How to create Animated No Chill Login form using HTML CSS and JS

    22 May 2025
    Facebook X (Twitter) Instagram YouTube Telegram Threads
    Coding StellaCoding Stella
    • Home
    • Blog
    • HTML & CSS
      • Login Form
    • JavaScript
    • Hire us!
    Coding StellaCoding Stella
    Home - JavaScript - How to create Cool Responsive Card Slider using HTML CSS & JavaScript
    JavaScript

    How to create Cool Responsive Card Slider using HTML CSS & JavaScript

    Coding StellaBy Coding Stella17 January 2025No Comments5 Mins Read
    Share Facebook Twitter Pinterest LinkedIn Tumblr Reddit Email WhatsApp Copy Link

    Let’s create a Cool Responsive Card Slider using HTML, CSS, and JavaScript. This project will feature a slider that showcases multiple cards, offering a seamless and interactive experience across all screen sizes.

    We’ll use HTML to structure the slider, CSS to style it and ensure responsiveness, and JavaScript to handle the sliding functionality and interactions.

    Let’s get started on building the Cool Responsive Card Slider. Whether you’re a beginner or an experienced developer, this project is a great way to enhance your web development skills and create an engaging element for your websites. Let’s slide into action!

    HTML :

    This HTML sets up a Swiper slider displaying cards with images, badges, titles, and buttons. It includes pagination, navigation buttons, and links external styles and scripts for functionality and design.

    <!DOCTYPE html>
    <html lang="en">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>Card Slider HTML & CSS | @coding.stella</title>
      <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@24,400,0,0" />
      <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css">
      <link rel="stylesheet" href="style.css">
    </head>
    <body>
      <div class="container swiper">
        <div class="card-wrapper">
          <!-- Card slides container -->
          <ul class="card-list swiper-wrapper">
            <li class="card-item swiper-slide">
              <a href="#" class="card-link">
                <img src="images/designer.jpg" alt="Card Image" class="card-image">
                <p class="badge badge-designer">Designer</p>
                <h2 class="card-title">Lorem ipsum dolor sit explicabo adipisicing elit</h2>
                <button class="card-button material-symbols-rounded">arrow_forward</button>
              </a>
            </li>
            <li class="card-item swiper-slide">
              <a href="#" class="card-link">
                <img src="images/developer.png" alt="Card Image" class="card-image">
                <p class="badge badge-developer">Developer</p>
                <h2 class="card-title">Lorem ipsum dolor sit explicabo adipisicing elit</h2>
                <button class="card-button material-symbols-rounded">arrow_forward</button>
              </a>
            </li>
            <li class="card-item swiper-slide">
              <a href="#" class="card-link">
                <img src="images/marketer.jpg" alt="Card Image" class="card-image">
                <p class="badge badge-marketer">Marketer</p>
                <h2 class="card-title">Lorem ipsum dolor sit explicabo adipisicing elit</h2>
                <button class="card-button material-symbols-rounded">arrow_forward</button>
              </a>
            </li>
            <li class="card-item swiper-slide">
              <a href="#" class="card-link">
                <img src="images/gamer.jpg" alt="Card Image" class="card-image">
                <p class="badge badge-gamer">Gamer</p>
                <h2 class="card-title">Lorem ipsum dolor sit explicabo adipisicing elit</h2>
                <button class="card-button material-symbols-rounded">arrow_forward</button>
              </a>
            </li>
            <li class="card-item swiper-slide">
              <a href="#" class="card-link">
                <img src="images/editor.jpg" alt="Card Image" class="card-image">
                <p class="badge badge-editor">Editor</p>
                <h2 class="card-title">Lorem ipsum dolor sit explicabo adipisicing elit</h2>
                <button class="card-button material-symbols-rounded">arrow_forward</button>
              </a>
            </li>
          </ul>
    
           <!-- Pagination -->
          <div class="swiper-pagination"></div>
    
          <!-- Navigation Buttons -->
          <div class="swiper-slide-button swiper-button-prev"></div>
          <div class="swiper-slide-button swiper-button-next"></div>
        </div>
      </div>
    
      <!-- Linking SwiperJS script -->
      <script src="https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.js"></script>
    
      <!-- Linking custom script -->
      <script src="script.js"></script>
    </body>
    </html>

    CSS :

    This CSS styles a responsive card slider with a gradient background, rounded white cards, hover effects, badges, and a clean modern design. It ensures smooth interactions, pagination styling, and hides navigation buttons on smaller screens.

    @import url('https://fonts.googleapis.com/css2?family=Inter:opsz,wght@14..32,100..900&display=swap');
    
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
      font-family: "Inter", sans-serif;
    }
    
    body {
      display: flex;
      align-items: center;
      justify-content: center;
      min-height: 100vh;
      background: linear-gradient(#ECEFFE, #C5CFFC);
    }
    
    .card-wrapper {
      max-width: 1100px;
      margin: 0 60px 35px;
      padding: 20px 10px;
      overflow: hidden;
    }
    
    .card-list .card-item {
      list-style: none;
    }
    
    .card-list .card-item .card-link {
      display: block;
      background: #fff;
      padding: 18px;
      user-select: none;
      border-radius: 12px;
      text-decoration: none;
      border: 2px solid transparent;
      box-shadow: 0 10px 10px rgba(0, 0, 0, 0.05);
      transition: 0.2s ease;
    }
    
    .card-list .card-item .card-link:active {
      cursor: grabbing;
    }
    
    .card-list .card-item .card-link:hover {
      border-color: #5372F0;
    }
    
    .card-list .card-link .card-image {
      width: 100%;
      border-radius: 10px;
      aspect-ratio: 16 / 9;
      object-fit: cover;
    }
    
    .card-list .card-link .badge {
      color: #5372F0;
      width: fit-content;
      padding: 8px 16px;
      font-size: 0.95rem;
      border-radius: 50px;
      font-weight: 500;
      background: #DDE4FF;
      margin: 16px 0 18px;
    }
    
    .card-list .card-link .badge-designer {
      color: #B22485;
      background: #F7DFF5;
    }
    
    .card-list .card-link .badge-marketer {
      color: #B25A2B;
      background: #FFE3D2;
    }
    
    .card-list .card-link .badge-gamer {
      color: #205C20;
      background: #D6F8D6;
    }
    
    .card-list .card-link .badge-editor {
      color: #856404;
      background: #fff3cd;
    }
    
    .card-list .card-link .card-title {
      color: #000;
      font-size: 1.19rem;
      font-weight: 600;
    }
    
    .card-list .card-link .card-button {
      height: 35px;
      width: 35px;
      color: #5372F0;
      margin: 30px 0 5px;
      background: none;
      cursor: pointer;
      border-radius: 50%;
      border: 2px solid #5372F0;
      transform: rotate(-45deg);
      transition: 0.4s ease;
    }
    
    .card-list .card-link:hover .card-button {
      color: #fff;
      background: #5372F0;
    }
    
    .card-wrapper .swiper-pagination-bullet {
      height: 13px;
      width: 13px;
      opacity: 0.5;
      background: #5372F0;
    }
    
    .card-wrapper .swiper-pagination-bullet-active {
      opacity: 1;
    }
    
    .card-wrapper .swiper-slide-button {
      color: #5372F0;
      margin-top: -35px;
    }
    
    /* Responsive media query code for small screens */
    @media (max-width: 768px) {
      .card-wrapper {
        margin: 0 10px 25px;
      }
    
      .card-wrapper .swiper-slide-button {
        display: none;
      }
    }

    JavaScript:

    This code initializes a Swiper slider on elements with the class .card-wrapper. It enables looping, sets space between slides to 30px, adds clickable pagination bullets, navigation arrows, and adjusts the number of visible slides based on screen width (1 for small, 2 for medium, and 3 for large screens).

    new Swiper('.card-wrapper', {
        loop: true,
        spaceBetween: 30,
    
        // Pagination bullets
        pagination: {
            el: '.swiper-pagination',
            clickable: true,
            dynamicBullets: true
        },
    
        // Navigation arrows
        navigation: {
            nextEl: '.swiper-button-next',
            prevEl: '.swiper-button-prev',
        },
    
        // Responsive breakpoints
        breakpoints: {
            0: {
                slidesPerView: 1
            },
            768: {
                slidesPerView: 2
            },
            1024: {
                slidesPerView: 3
            }
        }
    });

    In conclusion, building a Cool Responsive Card Slider using HTML, CSS, and JavaScript has been an exciting and educational journey. By combining HTML for structure, CSS for styling and responsiveness, and JavaScript for interactivity, we’ve crafted a dynamic and user-friendly slider.

    If your project has problems, don’t worry. Just click to download the source code and face your coding challenges with excitement. Have fun coding!

    3d animations Animation apple navigation bar navigation menu
    Share. Copy Link Twitter Facebook LinkedIn Email WhatsApp
    Previous ArticleHow to create Apple Dock Navigation Bar using HTML CSS & JavaScript
    Next Article How to create Personal Portfolio using HTML CSS & JavaScript
    Coding Stella
    • Website

    Related Posts

    HTML & CSS

    How to make Happy birthday cake Animation using HTML & CSS

    29 May 2025
    JavaScript

    How to create Toast Catcher Game using HTML CSS and JS

    26 May 2025
    JavaScript

    How to create Animated No Chill Login form using HTML CSS and JS

    22 May 2025
    Add A Comment
    Leave A Reply Cancel Reply

    Trending Post

    Master Frontend in 100 Days Ebook

    2 March 202419K Views

    How to make Modern Login Form using HTML & CSS | Glassmorphism

    11 January 202416K Views

    How to make I love you Animation in HTML CSS & JavaScript

    14 February 202414K Views

    How to make Valentine’s Day Card using HTML & CSS

    13 February 202412K Views
    Follow Us
    • Instagram
    • Facebook
    • YouTube
    • Twitter
    ads
    Featured Post

    How to make Social media icons hover effect using HTML & CSS

    14 May 2025

    How to make Hoverable Sidebar Menu using HTML CSS & JavaScript

    12 January 2024

    How to Make Moon Animation Using Pure CSS

    5 January 2024

    How to make 9 Dot Navigation Menu in HTML CSS & JavaScript

    12 January 2024
    Latest Post

    How to make Happy birthday cake Animation using HTML & CSS

    29 May 2025

    How to create Toast Catcher Game using HTML CSS and JS

    26 May 2025

    How to create Animated No Chill Login form using HTML CSS and JS

    22 May 2025

    How to make Social media icons hover effect using HTML & CSS

    14 May 2025
    Facebook X (Twitter) Instagram YouTube
    • About Us
    • Privacy Policy
    • Return and Refund Policy
    • Terms and Conditions
    • Contact Us
    • Buy me a coffee
    © 2025 Coding Stella. Made with 💙 by @coding.stella

    Type above and press Enter to search. Press Esc to cancel.

    Ad Blocker Enabled!
    Ad Blocker Enabled!
    Looks like you're using an ad blocker. We rely on advertising to help fund our site.
    Okay! I understood