Adjusting the height of images in flex layout - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Flex Height

Description

Adjusting the height of images in flex layout

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">
html {<!--  w ww.  j  av  a  2s .  c  om-->
   box-sizing:border-box;
}

*, *:before, *:after {
   margin:0;
   padding:0;
   box-sizing:inherit;
}

#all {
   display:flex;
   flex-direction:column;
   height:100vh;
   background:Chartreuse;
}

#app-container {
   margin:auto;
}

#app {
   width:501px;
   background:yellow;
   border:7px solid blue;
}

header {
   display:flex;
   justify-content:center;
   align-items:center;
   border:5px solid pink;
   height:21vh;
}

#header-para-container {
   flex:2;
}

#header-image-container {
   flex:0.7;
   background:WhiteSmoke;
   height:100%;
}

#header-image-container>img {
   height:100%;
}

section {
   display:flex;
   flex-wrap:wrap;
   border:5px solid OrangeRed;
   height:61vh;
}

figure {
   display:flex;
   justify-content:center;
   align-items:center;
   flex-basis:51%;
   border:5px solid grey;
   height:51%;
}

figure>img {
   height:100%;
}
</style> 
 </head> 
 <body> 
  <div id="all"> 
   <div id="app-container"> 
    <div id="app"> 
     <header> 
      <div id="header-para-container"> 
       <p>Hello, this is CSS flexbox layout. Thank you for visiting this page.</p> 
      </div> 
      <div id="header-image-container"> 
       <img src="https://www.java2s.com/style/demo/Google-Chrome.png"> 
      </div> 
     </header> 
     <section id="grid-images"> 
      <figure> 
       <img src="https://www.java2s.com/style/demo/Firefox.png"> 
      </figure> 
      <figure> 
       <img src="https://www.java2s.com/style/demo/Google-Chrome.png"> 
      </figure> 
      <figure> 
       <img src="https://www.java2s.com/style/demo/InternetExplorer.png"> 
      </figure> 
      <figure> 
       <img src="https://www.java2s.com/style/demo/Opera.png"> 
      </figure> 
     </section> 
    </div> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials