Skip to content

Instantly share code, notes, and snippets.

@jofralogo
Last active August 29, 2015 14:11
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 jofralogo/df0a1e4db94012dd620a to your computer and use it in GitHub Desktop.
Save jofralogo/df0a1e4db94012dd620a to your computer and use it in GitHub Desktop.
Mixins for easy vertical and horizontal center alignment with SCSS
@mixin vertical-align {
position: relative;
top: 50%;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
}
@mixin horizontal-align {
position: relative;
left: 50%;
-webkit-transform: translateX(-50%);
-ms-transform: translateX(-50%);
transform: translateX(-50%);
}
.vcenter{
@include vertical-align;
}
.hcenter{
@include horizontal-align;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment