Flexbox CSS Vertical Alignment to Central - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Flex Align

Description

Flexbox CSS Vertical Alignment to Central

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">
#servicesGrid<!--from  ww  w .  j ava  2  s .c om-->
 {
   position:absolute;
   top:0;
   left:0;
   width:100%;
   height:100%;
}

.service
 {
   width:25.86%;
   height:46%;
   background:Chartreuse;
   display:block;
   float:left;
   margin:0 0.3% 0 0;
   text-align:center;
}

#servicesGrid .service:nth-of-type(1)
 {
   width:100%;
   margin:0 0 0.3% 0;
   height:81%;
}

#servicesGrid .service:nth-of-type(5)
 {
   margin-right:0;
}

.serviceContent
 {
   margin:0;
   width:100%;
   height:100%;
   display:flex;
   align-items:center;
   color:yellow;
   text-align:center;
}

.button
 {
   color:blue;
   border:3px solid pink;
   border-radius:16px;
   padding:11px 21px 11px 21px;
   text-transform:uppercase;
   font-family:'Effra-Regular';
   text-decoration:none;
   transition:all linear 0.4s;
   -webkit-transition:all linear 0.4s;
   -moz-transition:all linear 0.4s;
}

.button:hover
 {
   color:WhiteSmoke;
   background:OrangeRed;
}
</style> 
 </head> 
 <body> 
  <div id="servicesGrid"> 
   <div class="service"> 
    <div class="serviceContent"> 
     <div style="margin-left:auto; margin-right:auto"> 
      <h1 style="font-size:40px; margin-bottom:-10px">Service</h1> 
      <h4>Lorem ipsum dolor sit amet</h4> 
      <br> 
      <a href="#contactUs" class="button" alt="Find Out More Button">Find Out More</a> 
     </div> 
    </div> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials