Close Menu

    Subscribe to Updates

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

    What's Hot

    How to create Valentine’s Love Button Animation using HTML CSS and JS

    23 June 2025

    How to create Magic Indicator Menu using HTML CSS and JS

    20 June 2025

    How to create Awesome Cool Loading Animation using HTML CSS and JS

    16 June 2025
    Facebook X (Twitter) Instagram YouTube Telegram Threads
    Coding StellaCoding Stella
    • Home
    • Blog
    • HTML & CSS
      • Login Form
    • JavaScript
    • Hire us!
    Coding StellaCoding Stella
    Home - HTML & CSS - How to Create 3D Hovering Cards using HTML CSS
    HTML & CSS

    How to Create 3D Hovering Cards using HTML CSS

    Coding StellaBy Coding Stella10 January 2024Updated:14 January 2024No Comments4 Mins Read
    Share Facebook Twitter Pinterest LinkedIn Tumblr Reddit Email WhatsApp Copy Link

    Curious about making your website pop? Our tutorial covers how to create those cool 3D hovering cards you’ve seen around! Using just HTML and CSS, you’ll learn step by step how to make cards that float and move when someone checks out your site.

    We’ll start with the basics in HTML, setting up the cards with the content you want. Then, with CSS magic, we’ll bring them to life, making them hover and react in a 3D way when someone hovers over them.

    These cards are like magnets for attention! They’ll make your website more interactive and eye-catching, perfect for showcasing anything from products to your best work. Get ready to make your website stand out with these awesome 3D hovering cards!

    HTML :

    The provided code is an HTML document template setting up a hovering effect on cards. It includes three cards with images and their respective hover effects, defined through CSS classes. The images are linked from Google Drive, and the design aims to create an engaging interactive experience for users by showcasing floating cards upon hover.

    The linked stylesheet “style.css” likely contains the specific CSS rules defining these hovering effects.

    <div id="cards">
      <div class="card" data-color="blue">
        <img class="card-front-image card-image" src="https://codingstella.com/wp-content/uploads/2024/01/download-1.webp" />
        <div class="card-faders">
          <img class="card-fader card-image" src="https://codingstella.com/wp-content/uploads/2024/01/download-1.webp" />
          <img class="card-fader card-image" src="https://codingstella.com/wp-content/uploads/2024/01/download-1.webp" />
          <img class="card-fader card-image" src="https://codingstella.com/wp-content/uploads/2024/01/download-1.webp" />
          <img class="card-fader card-image" src="https://codingstella.com/wp-content/uploads/2024/01/download-1.webp" />
          <img class="card-fader card-image" src="https://codingstella.com/wp-content/uploads/2024/01/download-1.webp" />
          <img class="card-fader card-image" src="https://codingstella.com/wp-content/uploads/2024/01/download-1.webp" />
          <img class="card-fader card-image" src="https://codingstella.com/wp-content/uploads/2024/01/download-1.webp" />
          <img class="card-fader card-image" src="https://codingstella.com/wp-content/uploads/2024/01/download-1.webp" />
        </div>
      </div>
      <div class="card" data-color="green">
        <img class="card-front-image card-image" src="https://codingstella.com/wp-content/uploads/2024/01/download-2.webp" />
        <div class="card-faders">
          <img class="card-fader card-image" src="https://codingstella.com/wp-content/uploads/2024/01/download-2.webp" />
          <img class="card-fader card-image" src="https://codingstella.com/wp-content/uploads/2024/01/download-2.webp" />
          <img class="card-fader card-image" src="https://codingstella.com/wp-content/uploads/2024/01/download-2.webp" />
          <img class="card-fader card-image" src="https://codingstella.com/wp-content/uploads/2024/01/download-2.webp" />
          <img class="card-fader card-image" src="https://codingstella.com/wp-content/uploads/2024/01/download-2.webp" />
          <img class="card-fader card-image" src="https://codingstella.com/wp-content/uploads/2024/01/download-2.webp" />
          <img class="card-fader card-image" src="https://codingstella.com/wp-content/uploads/2024/01/download-2.webp" />
          <img class="card-fader card-image" src="https://codingstella.com/wp-content/uploads/2024/01/download-2.webp" />
        </div>
      </div>
      <div class="card" data-color="brown">
        <img class="card-front-image card-image" src="https://codingstella.com/wp-content/uploads/2024/01/download-3.webp" />
        <div class="card-faders">
          <img class="card-fader card-image" src="https://codingstella.com/wp-content/uploads/2024/01/download-3.webp" />
          <img class="card-fader card-image" src="https://codingstella.com/wp-content/uploads/2024/01/download-3.webp" />
          <img class="card-fader card-image" src="https://codingstella.com/wp-content/uploads/2024/01/download-3.webp" />
          <img class="card-fader card-image" src="https://codingstella.com/wp-content/uploads/2024/01/download-3.webp" />
          <img class="card-fader card-image" src="https://codingstella.com/wp-content/uploads/2024/01/download-3.webp" />
          <img class="card-fader card-image" src="https://codingstella.com/wp-content/uploads/2024/01/download-3.webp" />
          <img class="card-fader card-image" src="https://codingstella.com/wp-content/uploads/2024/01/download-3.webp" />
          <img class="card-fader card-image" src="https://codingstella.com/wp-content/uploads/2024/01/download-3.webp" />
        </div>
      </div>
    </div>

    CSS :

    The Below CSS code defines a hovering effect for cards, adjusting the background color on hover. It sets root variables for colors and employs media queries for responsive design. Cards change opacity and scale on hover and click, accompanied by fader images animating left and right. Media queries adjust layout and card sizes for different screen sizes. Keyframes dictate the animations for the fader images, creating a dynamic visual experience.

    :root {
      --blue-rgb: 92 192 249;
      --green-rgb: 125 161 35;
      --brown-rgb: 127 46 23;
    }
    
    html, body {
      background-color: black;
    }
    
    body {
      min-height: 100vh;
      padding: 0;
      margin: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: background-color 1000ms;
    }
    
    body:has(.card[data-color="blue"]:hover) {
      background-color: rgb(var(--blue-rgb) / 25%);
    }
    
    body:has(.card[data-color="blue"]:hover) {
      background-color: rgb(var(--blue-rgb) / 25%);
    }
    
    body:has(.card[data-color="green"]:hover) {
      background-color: rgb(var(--green-rgb) / 25%);
    }
    
    body:has(.card[data-color="brown"]:hover) {
      background-color: rgb(var(--brown-rgb) / 25%);
    }
    
    #cards {
      width: 100%;
      display: flex;
      justify-content: space-evenly;
    }
    
    .card {
      background-size: cover;
      background-position: center;
      position: relative;
      cursor: pointer;
      outline: none;
      transition: scale 100ms;
    }
    
    .card .card-front-image {
      position: relative;
      z-index: 2;
    }
    
    .card .card-image {
      width: clamp(300px, 20vw, 500px);
      aspect-ratio: 2 / 3;
      border-radius: clamp(0.5rem, 0.75vw, 2rem);
    }
    
    .card-faders {
      height: 100%;
      width: 100%;
      position: absolute;
      left: 0px;
      top: 0px;
      z-index: 1;
      opacity: 0;
      transition: opacity 1500ms;
      pointer-events: none;
    }
    
    .card:hover .card-faders {
      opacity: 1;
    }
    
    .card:active {
      scale: 0.98;
    }
    
    .card-fader {
      position: absolute;
      left: 0px;
      top: 0px;
    }
    
    .card-fader:nth-child(odd) {
      animation: fade-left 3s linear infinite;
    }
    
    .card-fader:nth-child(even) {
      animation: fade-right 3s linear infinite;
    }
    
    .card-fader:is(:nth-child(3), :nth-child(4)) {
      animation-delay: 750ms;
    }
    
    .card-fader:is(:nth-child(5), :nth-child(6)) {
      animation-delay: 1500ms;
    }
    
    .card-fader:is(:nth-child(7), :nth-child(8)) {
      animation-delay: 2250ms;
    }
    
    @media(max-width: 1200px) {
      body {    
        justify-content: flex-start;
        align-items: flex-start;
      }
      
      #cards {
        flex-direction: column; 
        align-items: center;
        gap: 4rem;
        padding: 4rem;
      }
      
      .card .card-image {
        width: 400px;    
      }
    }
    
    @media(max-width: 600px) {
      #cards {
        gap: 2rem;
        padding: 2rem;
      }
      
      .card {
        width: 80%;    
      }
      
      .card .card-image {
        width: 100%;    
      }
    }
    
    @keyframes fade-left {
      from {
        scale: 1;
        translate: 0%;
        opacity: 1;
      }
      
      to {
        scale: 0.8;
        translate: -30%;
        opacity: 0;
      }
    }
    
    @keyframes fade-right {
      from {
        scale: 1;
        translate: 0%;
        opacity: 1;
      }
      
      to {
        scale: 0.8;
        translate: 30%;
        opacity: 0;
      }
    }

    There you have it! We’ve just created awesome 3D Hovering Cards using HTML and CSS. Spice up your web content with these cool, interactive cards. Happy coding!

    If you run into any hiccups with your project , worry not. You can easily grab the source code for this project. Just hit the Download button to get started on your coding adventure. Happy coding!

    Cards Hovering
    Share. Copy Link Twitter Facebook LinkedIn Email WhatsApp
    Previous ArticleHow to Make Moon Animation Using Pure CSS
    Next Article How to make Responsive Footer using HTML & CSS
    Coding Stella
    • Website

    Related Posts

    HTML & CSS

    How to create Awesome Cool Loading Animation using HTML CSS and JS

    16 June 2025
    HTML & CSS

    How to Create Animated Bicycle Product Card using HTML & CSS

    1 June 2025
    HTML & CSS

    How to make Happy birthday cake Animation using HTML & CSS

    29 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 202417K Views

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

    14 February 202415K 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 Squid game loader using HTML & CSS

    27 August 2024

    How to make Ball Leaping Loader using HTML & CSS

    21 February 2024

    Top 10 Most Popular Programming Languages of All Time

    25 January 2024

    How to make Weather App using HTML CSS & JavaScript

    13 January 2024
    Latest Post

    How to create Valentine’s Love Button Animation using HTML CSS and JS

    23 June 2025

    How to create Magic Indicator Menu using HTML CSS and JS

    20 June 2025

    How to create Awesome Cool Loading Animation using HTML CSS and JS

    16 June 2025

    How to create Login and Signup Form using HTML CSS and JS

    9 June 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