Close Menu

    Subscribe to Updates

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

    What's Hot

    How to create Animated 404 Page not found using HTML and CSS

    29 July 2025

    How to create Reptile Interactive Cursor using HTML and JS

    27 July 2025

    How to create Cat Loading Animation using HTML and CSS

    23 July 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 make Smooth Parallax Scrolling Cards using HTML CSS & JavaScript
    JavaScript

    How to make Smooth Parallax Scrolling Cards using HTML CSS & JavaScript

    Coding StellaBy Coding Stella14 May 2024No Comments5 Mins Read
    Share Facebook Twitter Pinterest LinkedIn Tumblr Reddit Email WhatsApp Copy Link

    Let’s create Smooth Parallax Scrolling Cards using HTML, CSS, and JavaScript. This project will feature cards that smoothly animate and scroll with a parallax effect as the user scrolls down the webpage.

    We’ll keep it sleek and modern, using HTML for the card structure, CSS for styling and animations, and JavaScript to handle the smooth scrolling effect.

    Let’s dive into building the Smooth Parallax Scrolling Cards. Whether you’re a beginner or an experienced developer, this project offers a dynamic way to showcase content and add visual interest to your website. Let’s make scrolling through content a delightful experience!

    HTML :

    This HTML document sets up a webpage with smooth parallax scrolling cards. It includes a header with a title and a scroll icon, followed by a series of cards each containing an image. These cards create a parallax effect as you scroll down the page. The page also includes a space divider. Additionally, it links external CSS and JavaScript files for styling and functionality, respectively.

    <!DOCTYPE html>
    <html lang="en" >
    <head>
      <meta charset="UTF-8">
      <title> Smooth Parallax Scrolling Cards </title>
      <link rel="stylesheet" href="./style.css">
    
    </head>
    <body>
    <!-- partial:index.partial.html -->
    <div class="header">
      <h2>Smooth Parallax Scrolling Cards</h2>
      <svg
        class="scroll-icon"
        id="fi_7663989"
        viewBox="0 0 91 91"
        fill="currentColor"
        xmlns="http://www.w3.org/2000/svg"
        data-name="Layer 1"
      >
        <path
          d="m45.33 90a1.5 1.5 0 0 1 -1.5-1.5v-20.3a1.5 1.5 0 0 1 3 0v20.26a1.5 1.5 0 0 1 -1.5 1.54z"
        ></path>
        <path
          d="m45.33 90a1.5 1.5 0 0 1 -1-.38l-9-7.88a1.5 1.5 0 1 1 2-2.25l9 7.88a1.49 1.49 0 0 1 .15 2.11 1.52 1.52 0 0 1 -1.15.52z"
        ></path>
        <path
          d="m45.33 90a1.5 1.5 0 0 1 -1-2.63l9-7.88a1.5 1.5 0 1 1 2 2.25l-9 7.88a1.47 1.47 0 0 1 -1 .38z"
        ></path>
        <path
          d="m50.86 60.73h-11.07a15.13 15.13 0 0 1 -15.11-15.11v-29a15.13 15.13 0 0 1 15.11-15.16h11.07a15.12 15.12 0 0 1 15.14 15.11v29.05a15.12 15.12 0 0 1 -15.14 15.11zm-11.07-56.27a12.12 12.12 0 0 0 -12.11 12.11v29.05a12.13 12.13 0 0 0 12.11 12.11h11.07a12.12 12.12 0 0 0 12.14-12.11v-29a12.12 12.12 0 0 0 -12.14-12.16z"
        ></path>
        <path
          d="m45.33 26.37a1.5 1.5 0 0 1 -1.5-1.5v-7.53a1.5 1.5 0 0 1 3 0v7.53a1.5 1.5 0 0 1 -1.5 1.5z"
        ></path>
      </svg>
    </div>
    <div class="cards">
      <div class="card">
        <div class="card__image-wrapper">
          <img
            class="card__image"
            src="https://source.unsplash.com/random/1"
            alt=""
          />
        </div>
      </div>
      <div class="card">
        <div class="card__image-wrapper">
          <img
            class="card__image"
            src="https://source.unsplash.com/random/2"
            alt=""
          />
        </div>
      </div>
      <div class="card">
        <div class="card__image-wrapper">
          <img
            class="card__image"
            src="https://source.unsplash.com/random/3"
            alt=""
          />
        </div>
      </div>
      <div class="card">
        <div class="card__image-wrapper">
          <img
            class="card__image"
            src="https://source.unsplash.com/random/4"
            alt=""
          />
        </div>
      </div>
      <div class="card">
        <div class="card__image-wrapper">
          <img
            class="card__image"
            src="https://source.unsplash.com/random/5"
            alt=""
          />
        </div>
      </div>
      <div class="card">
        <div class="card__image-wrapper">
          <img
            class="card__image"
            src="https://source.unsplash.com/random/6"
            alt=""
          />
        </div>
      </div>
      <div class="card">
        <div class="card__image-wrapper">
          <img
            class="card__image"
            src="https://source.unsplash.com/random/7"
            alt=""
          />
        </div>
      </div>
      <div class="card">
        <div class="card__image-wrapper">
          <img
            class="card__image"
            src="https://source.unsplash.com/random/8"
            alt=""
          />
        </div>
      </div>
        <div class="card">
        <div class="card__image-wrapper">
          <img
            class="card__image"
            src="https://source.unsplash.com/random/9"
            alt=""
          />
        </div>
      </div>
        <div class="card">
        <div class="card__image-wrapper">
          <img
            class="card__image"
            src="https://source.unsplash.com/random/10"
            alt=""
          />
        </div>
      </div>
    </div>
    <div class="space"></div>
    <!-- partial -->
      <script  src="./script.js"></script>
    
    </body>
    </html>
    

    CSS :

    This CSS code styles a webpage with a header, grid-based card layout, and responsive design. It sets up the cards to display in two columns on larger screens and a single column on smaller screens. Each card has a square shape with rounded corners and contains an image. The header is centered vertically and includes a title and a scroll icon. The body has zero padding and margin, with a radial gradient background. Additionally, it adjusts font sizes and background gradients for smaller screens using media queries.

    .cards {
      display: grid;
      grid-template-columns: 300px 300px;
      gap: 10px;
    }
    
    .card {
      width: 100%;
      aspect-ratio: 1;
      overflow: hidden;
      border-radius: 20px;
    }
    
    .card__image-wrapper {
      height: 600px;
      will-change: transform;
    }
    
    .card__image {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }
    
    body {
      padding: 0 20px;
      margin: 0;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      background: rgb(150, 159, 204);
      background: radial-gradient(
        circle,
        hsl(230, 20%, 70%) 0%,
        rgba(239, 239, 244, 1) 100%
      );
    }
    
    .header {
      height: 50vh;
      min-height: 450px;
      display: flex;
      flex-direction: column;
      align-items: center;
    }
    
    .scroll-icon {
      width: 100px;
      color: rgb(57, 61, 80);
      margin-top: 50px;
    }
    
    h2 {
      font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
      font-size: 50px;
      text-align: center;
      color: rgb(65, 69, 85);
      max-width: 500px;
      margin: 80px 0 0;
    }
    
    .space {
      height: 40vh;
    }
    
    @media (max-width: 500px) {
      .cards {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
      }
    
      h2 {
        font-size: 38px;
      }
    
      .scroll-icon {
        width: 100px;
      }
    
      body {
        background: radial-gradient(
          circle,
          hsl(230, 20%, 70%) 50%,
          rgba(239, 239, 244, 1) 100%
        );
      }
    }

    JavaScript:

    This JavaScript code defines a ParallaxCard class responsible for creating a parallax effect on cards as the user scrolls. It calculates the scroll progress and adjusts the position of the card’s image wrapper accordingly to achieve the parallax effect. The initCardParallax function initializes the parallax effect for all card elements on the page, updating them continuously as the user scrolls.

    class ParallaxCard {
      constructor(cardEl) {
        this.cardEl = cardEl
        this.imageWrapper = cardEl.querySelector('.card__image-wrapper')
    
        this.heightDiff = this.imageWrapper.clientHeight - this.cardEl.clientHeight
      }
    
      update() {
        const boundingRect = this.cardEl.getBoundingClientRect()
        const topOffset = boundingRect.y
        const progress = topOffset / window.innerHeight
        const offset = this.heightDiff * progress * -1
        this.imageWrapper.style.transform = `translate(0, ${offset}px)`
      }
    }
    
    function initCardParallax() {
      const cardEls = document.querySelectorAll('.card')
      const cards = Array.from(cardEls).map((cardEl) => new ParallaxCard(cardEl))
    
      function update() {
        cards.forEach((card) => card.update())
      }
      
      function onScroll() {
        requestAnimationFrame(update)
      }
    
      window.addEventListener('scroll', onScroll)
      requestAnimationFrame(update)
    }
    
    initCardParallax()

    In conclusion, developing Smooth Parallax Scrolling Cards has been an engaging journey into modern web design. Through the combination of HTML, CSS, and JavaScript, we’ve created a visually captivating effect that enhances user experience by adding depth and interactivity to the webpage.

    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!

    Share. Copy Link Twitter Facebook LinkedIn Email WhatsApp
    Previous ArticleHow to make 3D wave animation using HTML & CSS
    Next Article How to make Music Player with Slider | Swiper JS using HTML CSS & JavaScript
    Coding Stella
    • Website

    Related Posts

    JavaScript

    How to create Reptile Interactive Cursor using HTML and JS

    27 July 2025
    JavaScript

    How to create Animated Fanta Website using HTML CSS and JS

    20 July 2025
    JavaScript

    How to create Airpods Animation using HTML CSS and JS

    15 July 2025
    Add A Comment
    Leave A Reply Cancel Reply

    Trending Post

    Master Frontend in 100 Days Ebook

    2 March 202421K Views

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

    11 January 202420K Views

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

    14 February 202417K Views

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

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

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

    22 May 2025

    How to Make Social Media Icons Popups in HTML and CSS

    12 December 2023

    How to make Glowing Neon Clock using HTML CSS & JavaScript

    23 June 2024

    How to make Sort the bubble clock using HTML CSS & JavaScript

    20 July 2024
    Latest Post

    How to create Animated 404 Page not found using HTML and CSS

    29 July 2025

    How to create Reptile Interactive Cursor using HTML and JS

    27 July 2025

    How to create Cat Loading Animation using HTML and CSS

    23 July 2025

    How to create Animated Fanta Website using HTML CSS and JS

    20 July 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