Kevin Powell - CommunityKP-C
Kevin Powell - Communityβ€’2y agoβ€’
11 replies
justAni

Increase additional height of a dynamic element

I wanted to increase the height ( ON HOVER to show the description ) of the div element which has a dynamic height of the inner element (i.e. an image), if someone can help me with this query it would be really helpful πŸ™

Basic HTML:
<article class="gallery">
          <div class="img-cont">
            <img src="https://plus.unsplash.com/premium_photo-1675378165346-5f6c3959f0d2?w=600&auto=format&fit=crop&q=60&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8MXx8cGFpbnRpbmd8ZW58MHx8MHx8fDA%3D" alt="">
            <div class="img-content">
              <h3 class="img-title">Lorem ipsum dolor sit, amet consectetur adipisicing elit.</h3>
              <span class="img-tag">Lorem, ipsum.</span>
            </div>
          </div>
          <div class="img-cont">
          ...
          ...

Basic CSS (just added the hover-effect on the image and not any other effects):
.gallery {
  max-width: var(--max-width);
  columns: 3;
  column-gap: 15px;
}
.img-cont {
  width: 100%;
  /* background: lightgray; */
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
  margin-bottom: 10px;
  box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.2);
  break-inside: avoid;
  overflow: hidden;
  transition: all 0.5s ease-in-out;
}

.img-cont:hover img {
  transform: scale(0.9) rotate(-2deg);
}

.img-cont img {
  width: 100%;
  transition: all 0.5s ease-in-out;
}

.img-content {
  display: flex;
  display: none;
  /* opacity: 0; */
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  z-index: 10;
  transition: all 0.5s ease-in-out;
  /* text-wrap: balance; */
}
dis-query.JPG
Was this page helpful?