Child with max-height: 100% overflows parent - HTML CSS CSS Property

HTML CSS examples for CSS Property:overflow

Description

Child with max-height: 100% overflows parent

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <style id="compiled-css" type="text/css">
.grid-container {<!--from w  w  w. j  av a 2 s  .co  m-->
   width:201px;
   height:201px;
   display:flex;
   background-color:Chartreuse;
}

.image-container {
   outline:6px solid red;
   max-width:100%;
   max-height:100%;
   display:flex;
}

img {
   max-width:100%;
   max-height:100%;
   display:block;
}
</style> 
 </head> 
 <body> 
  <h2>Lorem ipsum dolor sit amet, consectetur adipiscing elit</h2> 
  <div class="grid-container"> 
   <div class="widget-container"> 
    <div class="image-container"> 
     <img src="https://www.java2s.com/style/demo/Safari.png"> 
    </div> 
   </div> 
  </div> 
  <br> 
  <br> 
  <br> 
  <br> 
  <br> 
  <br> 
  <br> 
  <h2>Lorem ipsum dolor sit amet, co</h2> 
  <div class="grid-container"> 
   <div class="widget-container"> 
    <div class="image-container"> 
     <img src="https://www.java2s.com/style/demo/Safari.png"> 
    </div> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials