Skip to content

Instantly share code, notes, and snippets.

@carlsednaoui
Created February 1, 2014 05:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlsednaoui/8748589 to your computer and use it in GitHub Desktop.
Save carlsednaoui/8748589 to your computer and use it in GitHub Desktop.
CSS - Vertical Align
/*http://zerosixthree.se/vertical-align-anything-with-just-3-lines-of-css/*/
.element {
position: relative;
top: 50%;
transform: translateY(-50%);
}
@carlsednaoui
Copy link
Author

Here's another option:

.center-div {
  position: absolute;
  margin: auto;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100px;
  height: 100px;
  background-color: #ccc;
}

/src: http://www.tipue.com/blog/center-a-div/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment