JSFiddle - React, Tailwind, and code Playground

by PesecZ42

HTML

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <link rel="stylesheet" href="styles.css" />
  <title>Карточки | Проект 1</title>
</head>
<body>
<div class="container">
  <div
      class="slide"
      style="background-image: url('https://images.unsplash.com/photo-1558981403-c5f9899a28bc?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=1170&q=80');"
  >
    <h3>Harley-Davidson</h3>
  </div>
  <div
      class="slide"
      style="
          background-image: url('https://images.unsplash.com/photo-1622185135505-2d795003994a?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=1170&q=80');
        "
  >
    <h3>Royal Enfield</h3>
  </div>
  <div
      class="slide"
      style="
          background-image: url('https://images.unsplash.com/photo-1586529031518-d5bb5e30f41f?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=1172&q=80');
        "
  >
    <h3>Ducati</h3>
  </div>
  <div
      class="slide active"
      style="
          background-image: url('https://images.unsplash.com/photo-1508357710528-af900c15fe96?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=1170&q=80');
        "
  >
    <h3>Kawasaki</h3>
  </div>
  <div
      class="slide"
      style="
          background-image: url('https://images.unsplash.com/photo-1625229455730-7a9976551c36?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=782&q=80');
        "
  >
    <h3>BMW</h3>
  </div>
</div>
</body>
</html>

CSS

* {
  box-sizing: border-box;
}

body {
  font-family: 'Muli', sans-serif;
  overflow: hidden;
  margin: 0;
  background: #2F4F4F;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  }
  
  .container {
    width: 100%;
    display: flex;
    padding: 0 20px;
  }
   .slide {
     height: 80vh;
     border-radius: 20px;
     margin: 10px;
     cursor: pointer;
     color: #fff;
     flex: 1;
     background-size: cover;
     background-position: center;
     background-repeat: no-repeat;
     position: relative;
     transition: all 500ms ease-in-out;
     
   }
   .slide h3 {
     position: absolute;
     font-size: 24px;
     bottom: 20px;
     left: 20px;
     margin: 0;
     opacity: 0;
      
      }
   .slide.active {
     flex: 10;
     }
     
   .slide.active h3{
     opacity: 1;
     transition: opacity 0.3s ease-in 0.4s;
   }

JavaScript

const slides = document.querySelectorAll( '.slide')

for( const slide of slides) { 
 slide.addEventListener('click',() =>{
 clearActiveClasess()
 
 slide.classList.add('active')
 })

} 
function clearActiveClasess(){
slides.forEach( () => {
slide.classList.remove('.active')

})

}