Make Div center in the page vertically - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Div

Description

Make Div center in the page vertically

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">
* {<!--  w  w  w .  j  a  v  a2s .c  o m-->
   box-sizing:border-box;
}

html, body {
   height:100%;
}

main {
   background-color:Chartreuse;
}

.content {
   display:table;
}

.wrapper {
   position:relative;
   height:100%;
}

.content {
   width:1061px;
   position:absolute;
   padding:141px 0 201px 0;
   height:100%;
   top:0;
   left:51%;
   margin-left:-531px;
}

main {
   width:743px;
   position:relative;
   font-size:2.6em;
   display:table-cell;
   vertical-align:middle;
}

main .my {
   position:absolute;
   top:0;
   left:0;
   width:100%;
   height:100%;
   padding:11px;
   background-color:yellow;
   position:relative;
}

main .my article {
   background-color:blue;
   width:100%;
   height:100%;
   overflow-y:auto;
}
</style> 
 </head> 
 <body> 
  <div class="wrapper"> 
   <div class="content"> 
    <main> 
     <div class="my"> 
      <article id="home"> 
       <h1>This is the home page</h1> 
       <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptate quae ipsa dolor quidem ipsum, repudiandae maiores ad aliquam in necessitatibus incidunt. Quibusdam alias beatae temporibus culpa, esse ipsam, rem ducimus.</p> 
       <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptate quae ipsa dolor quidem ipsum, repudiandae maiores ad aliquam in necessitatibus incidunt. Quibusdam alias beatae temporibus culpa, esse ipsam, rem ducimus.</p> 
      </article> 
     </div> 
    </main> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials