1

html

<div class="elementor-testimonial__footer">
    <div class="elementor-testimonial__image"> 
        <img src="https://roommi-tw.com/wp-content/uploads/room4.jpg">
    </div>
</div>

css

.elementor-testimonial__footer {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 66.67%;
    overflow: hidden;
}
.elementor-testimonial__image {
    width: 100%;
    height: 100%; // something weird just happened
}
elementor-testimonial__image img {
    width: 100%;
}

I set the height of the .elementor-testimonial__image div 100%, but the result rendered is 0%.

enter image description here So I removed the code:

.elementor-testimonial__image {
    width: 100%;
    height: 100%;
}

After removing those lines, something weird just happened: the position of the image is change as you can see in the picture below. enter image description here

Can anyone please explain this to me? Thank you!

#test-container {
  width: 300px;
  height: 200px;
  border: 1px solid #000;
}
.elementor-testimonial__footer {
  position: relative;
  width: 100%;
  height: 0;
  padding-bottom: 66.67%;
  overflow: hidden;
  margin-bottom: 18px;
}
.elementor-testimonial__image {
 width: 100%;
  height: 100%;
}
.elementor-testimonial__image img {
 width: 100%;
}


Edited: This is a brief code I captured from the Wordpress template but the result seems fine. I guess there are some code that has conflict but I still cannot find out... (Still working on it!)
<div id="test-container">
  <div class="elementor-testimonial__footer">
    <div class="elementor-testimonial__image">
      <img src="https://roommi-tw.com/wp-content/uploads/room4.jpg">
    </div> 
  </div>
  <div class="elementor-testimonial__content">
    
      It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal     
  </div>
</div>
hayley
  • 384
  • 5
  • 17

1 Answers1

1

As already mentioned, the 100% height of div .elementor-testimonial__image has no effect (100% of 0px). But the image is visible, because it overflows its parent container using the picture's height.

Additionally:

  • Add missing dot (".") to class selector elementor-testimonial__image img (if you want to use it)
  • Always use /* .... */-style comments in CSS. Just because // works in most browsers doesn't mean it's correct.
Freddy
  • 4,548
  • 1
  • 7
  • 17