Skip to content

Instantly share code, notes, and snippets.

@jedfoster
Last active August 29, 2015 14:18
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 jedfoster/0571ecd5f983eacd7899 to your computer and use it in GitHub Desktop.
Save jedfoster/0571ecd5f983eacd7899 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// libsass (v3.2.5)
// ----
// In response to https://twitter.com/jed_foster/status/582955571428483072
// Notice how this doesn't suck.
// Align an object with absolute positioning
// Used to align the Big Play Button in the corners or center
@mixin absolute-align($align, $margin, $length) {
@if ($align == center) {
/* Center it horizontally */
left: 50%;
margin-left: -$length/2;
}
@else if ($align == middle) {
/* Center it vertically */
top: 50%;
margin-top: -$length/2;
}
@else {
#{$align}: $margin;
}
}
.foo {
@include absolute-align(middle, 10px, 10px);
}
.foo {
/* Center it vertically */
top: 50%;
margin-top: -5px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment