Fixed expanding card transitions Using HTML, CSS, and JS

Hey, learner today In this Post, we are going to Create Fixed expanding card transitions Using HTML, CSS, and JS. In the past post, we have created many projects one of them  Analogue Clock using HTML, CSS, and JS. Now it is time to create expanding card transitions.

Fixed expanding card transitions Using HTML, CSS, and JS

In this article, we have created an expanding card transition using HTML, CSS, and Js. This cool HTML, CSS, and JavaScript transition effect can easily be implemented on any type of website. The transition can be used for sliders and other types of elements on the site, like cards. In this transition, we have put 5 slides with different images. If One side is open all others are closed.

Preview of Fixed expanding card transitions on Codepen

Codepen Link

You might like this

Fixed expanding card transitions Using HTML, CSS, and JS [Source code]

To create Fixed expanding card transitions Using HTML, CSS, and JS you have to create three files (HTML, CSS, and JS) files with the named index.html, style.css, and Script.js in the same folder and you have to link the CSS and JS file to HTML. after that paste, the HTML code in index.html, and paste the CSS code in style.css at last paste the Javascript code in Script.js that’s all after pasting the code.

At first, you have to create an HTML file with the named index.html and paste the below HTML code on it and save it. Remember to give a .html extension to the HTML file.

<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" href="style.css" />
    <title>Expanding Cards</title>
    <div class="container">
      <div class="panel active" style="background-image: url('')">
        <h3>Explore The World</h3>
      <div class="panel" style="background-image: url('')">
        <h3>Wild Forest</h3>
      <div class="panel" style="background-image: url('')">
        <h3>Sunny Beach</h3>
      <div class="panel" style="background-image: url('')">
        <h3>City on Winter</h3>
      <div class="panel" style="background-image: url('')">
        <h3>Mountains - Clouds</h3>


    <script src="script.js"></script>

After pasting the HTML code, Now have to create a second CSS file with the named style.css. Paste the below code on it and save it. Again remember to give .css extension to CSS file.

@import url('');

* {
  box-sizing: border-box;

body {
  background-color: #1792D5;
  font-family: 'Muli', sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  overflow: hidden;
  margin: 0;

.container {
  display: flex;
  width: 90vw;

.panel {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  height: 80vh;
  border-radius: 50px;
  color: #fff;
  cursor: pointer;
  flex: 0.5;
  margin: 10px;
  position: relative;
  -webkit-transition: all 700ms ease-in;

.panel h3 {
  font-size: 24px;
  position: absolute;
  bottom: 20px;
  left: 20px;
  margin: 0;
  opacity: 0;
} {
  flex: 5;
} h3 {
  opacity: 1;
  transition: opacity 0.3s ease-in 0.4s;

@media (max-width: 480px) {
  .container {
    width: 100vw;

  .panel:nth-of-type(5) {
    display: none;

At last, you have to create a Javascript file with the named script.js and paste the Js code on it and save it again don’t forget to give the .js extension to the Javascript file.

const panels = document.querySelectorAll('.panel')

panels.forEach(panel => {
    panel.addEventListener('click', () => {

function removeActiveClasses() {
    panels.forEach(panel => {

That’s all after pasting the code now your code will be successfully run. If you get any kind of error/problem in the code just comment down or contact me

2 thoughts on “Fixed expanding card transitions Using HTML, CSS, and JS”

Leave a Comment