Vertically Center Anything With Dimensions

One way to easily vertically center a div is to set it to be absolute, set the width, height and then the top, bottom, left and right all equal to 0.  Something like this:

.vertically-centered-box {

  position:absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  width:100px;
  height:100px;
  margin:auto;

}

From: http://stackoverflow.com/questions/356809/best-way-to-center-a-div-on-a-page-vertically-and-horizontally

Tagged with:

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.