Flexbox vertically align content - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Flex Align

Description

Flexbox vertically align content

Demo Code

ResultView the demo in separate window

<html lang="en">
 <head> 
  <title>  Paulie-D</title> 
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> 
  <style>
#mainpage-container {<!--from ww  w .  j av  a 2s. c  om-->
   display:flex;
   align-items:center;
   justify-content:center;
   flex-direction:column;
   flex-wrap:wrap;
}

#mainpage-container section {
   width:100%;
   height:100vh;
   text-align:center;
}

#mainpage-container .initial {
   background-color:Chartreuse;
   color:yellow;
   display:flex;
   align-items:center;
   justify-content:center;
   font-size:4rem;
}

#mainpage-container .initial #logo {
   height:16rem;
   width:auto;
}
</style> 
 </head> 
 <body translate="no"> 
  <div id="mainpage-container"> 
   <section class="initial"> 
    <!--<img src="https://www.java2s.com/style/demo/InternetExplorer.png" id="logo">--> 
    <p>Lorem ipsum.</p> 
   </section> 
   <section> 
   </section> 
   <section> 
   </section> 
  </div>  
 </body>
</html>

Related Tutorials