Created
February 20, 2018 22:22
Revisions
-
tankbar created this gist
Feb 20, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ @mixin centerer($horizontal: true, $vertical: true) { position: absolute; @if ($horizontal and $vertical) { top: 50%; left: 50%; transform: translate(-50%, -50%); } @else if ($horizontal) { left: 50%; transform: translate(-50%, 0); } @else if ($vertical) { top: 50%; transform: translate(0, -50%); } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ <div class=“parent”> <div class=“child both”>I’m centered on both axis!</div> </div> <div class=“parent”> <div class=“child horizontal”>I’m centered horizontally!</div> </div> <div class=“parent”> <div class=“child vertical”>I’m centered vertically!</div> </div> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ .parent { position: relative; } .child { &.both { @include centerer; } &.horizontal { @include centerer(true, false); } &.vertical { @include centerer(false, true); } }