Image sizing in flexbox - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Flex Container

Description

Image sizing in flexbox

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 {<!--from ww  w.  j a v  a  2  s  . c o m-->
   box-sizing: border-box;
}
*, *:before, *:after {
   box-sizing: inherit;
}
.loading-spinner-overlay-1 {
   background-color: aliceblue;
   left: 0;
   top: 60px;
   right: calc(100% - 300px);
   bottom: calc(100% - 300px);
   position: absolute;
   z-index: 9999;
   display: flex;
   align-items: center;
   justify-content: center;
}
.loading-spinner-overlay-2 {
   background-color: aliceblue;
   left: 0;
   top: 300px;
   right: calc(100% - 300px);
   bottom: calc(100% - 600px);
   position: absolute;
   z-index: 9999;
   display: flex;
   align-items: center;
   justify-content: center;
}
.loading-spinner-background {
   min-width: 100px;
   max-width: 50%;
   background-color: white;
   border-radius: 10px;
   display: flex;
   z-index: 1;
   padding: 20px;
}
.loading-spinner-container {
   min-height: 60px;                       
   display: flex;
   flex-direction: column;
   flex-grow: 1;
   align-items: center;                    
   justify-content: center;                
   width: 100%;
}
.loading-spinner-container > p {
   text-align: center;
   margin: 0;
   width: 100%;
}


      </style> 
 </head> 
 <body> 
  <img src="https://www.java2s.com/style/demo/InternetExplorer.png"> 
  <div class="loading-spinner-overlay-1"> 
   <div class="loading-spinner-background"> 
    <div class="loading-spinner-container"> 
     <img src="https://www.java2s.com/style/demo/InternetExplorer.png"> 
    </div> 
   </div> 
  </div> 
  <div class="loading-spinner-overlay-2"> 
   <div class="loading-spinner-background"> 
    <div class="loading-spinner-container"> 
     <img src="https://www.java2s.com/style/demo/Google-Chrome.png"> 
     <p> Some very long long long text </p> 
    </div> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials