Project 1 - Displaying Cards

 About:

    In this Blog , I will be designing responsive cards. I am implementing this using simple Html, Css and JavaScript , we are not using any frameworks.

For this, I took 5 images of Seven Wonders in the world. I am using three files here, You can find the source for this and for output , you can refer to the video below.

I am attaching images I used for your reference, You have to create a Assests folder and have to place these images in it.

Index.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="style.css" />
    <title>Expanding Cards</title>
  </head>
  <body>
    <div class="container">
      <div class="panel active" style="background-image: url('./Assets/Christ_the_redeemer.jpg')">
        <h3>Christ The Redeemer</h3>
      </div>
      <div class="panel" style="background-image: url('./Assets/colosseum.jpg')">
        <h3>Colosseum</h3>
      </div>
      <div class="panel" style="background-image: url('./Assets/Great_wall_of_China.jpg')">
        <h3>Great Wall Of China</h3>
      </div>
      <div class="panel" style="background-image: url('./Assets/TajMahal.jpg')">
        <h3>Taj Mahal</h3>
      </div>
      <div class="panel" style="background-image: url('./Assets/MachiPicchu.jpg')">
        <h3>Machi Picchu</h3>
      </div>

    </div>

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



Style.css -
@import url('https://fonts.googleapis.com/css?family=Muli&display=swap');

* {
  box-sizingborder-box;
}

body {
  font-family'Muli'sans-serif;
  displayflex;
  align-itemscenter;
  justify-contentcenter;
  height100vh;
  overflowhidden;
  margin0;
}

.container {
  displayflex;
  width90vw;
}

.panel {
  background-sizecover;
  background-positioncenter;
  background-repeatno-repeat;
  height80vh;
  border-radius50px;
  color#fff;
  cursorpointer;
  flex0.5;
  margin10px;
  positionrelative;
  -webkit-transitionall 700ms ease-in;
}

.panel h3 {
  font-size24px;
  positionabsolute;
  bottom20px;
  left20px;
  margin0;
  opacity0;
}

.panel.active {
  flex5;
}

.panel.active h3 {
  opacity1;
  transition: opacity 0.3s ease-in 0.4s;
}

@media (max-width480px) {
  .container {
    width100vw;
  }

  .panel:nth-of-type(4),
  .panel:nth-of-type(5) {
    displaynone;
  }
}

script.js -
const panels = document.querySelectorAll('.panel')

panels.forEach(panel => {
    panel.addEventListener('click', () => {
        removeActiveClasses()
        panel.classList.add('active')
    })
})

function removeActiveClasses() {
    panels.forEach(panel => {
        panel.classList.remove('active')
    })
}

  

OUTPUT:-

    


Images for Reference:







Comments

Post a Comment

If you any doubts or Modifications I have to do, let me know.

Popular posts from this blog

Project 3 - Customized Rotating Navigation

Project 2 - Progress Steps

Project 5 - Customized Scroll Animation