1- // Lost Grid v4.0.0 - https://github.com/corysimmons/lost
1+ // Lost Grid v4.0.1 - https://github.com/corysimmons/lost
22
33$gutter : 30px !default ;
44$rtl : false !default ;
@@ -69,11 +69,21 @@ $rtl: false !default;
6969
7070/// Vertically and/or horizontally align nested elements.
7171///
72- /// @param {string} $dir [both] - Direction. Either vertical, v, horizontal, or h. Defaults to both.
72+ /// @param {string} $location [middle-center] - The position the nested element takes relative to the containing element.
73+ ///
74+ /// - reset
75+ /// - top-left
76+ /// - top-center or top
77+ /// - top-right
78+ /// - middle-left or left
79+ /// - middle-right or right
80+ /// - bottom-left
81+ /// - bottom-center or bottom
82+ /// - bottom-right
7383///
7484/// @example
7585/// .parent {
76- /// @include align(vertical) ;
86+ /// @include align;
7787/// width: 600px;
7888/// height: 400px;
7989/// .child {
@@ -82,25 +92,70 @@ $rtl: false !default;
8292/// }
8393/// }
8494
85- @mixin align ($dir : both ) {
95+ @mixin align ($location : middle - center ) {
8696 position : relative ;
8797 > * {
8898 position : absolute ;
89- transform-style : preserve-3d ;
90- @if ($dir == ' horizontal' ) or ($dir == ' h' ) {
99+ @if ($location == reset ) {
100+ top : auto ;
101+ right : auto ;
102+ bottom : auto ;
103+ left : auto ;
104+ transform : translate3d (0 , 0 , 0 );
105+ } @else if ($location == top- left) {
106+ top : 0 ;
107+ right : auto ;
108+ bottom : auto ;
109+ left : 0 ;
110+ transform : translate3d (0 , 0 , 0 );
111+ } @else if ($location == top- center) or ($location == top ) {
112+ top : 0 ;
113+ right : auto ;
114+ bottom : auto ;
91115 left : 50% ;
92- transform : translateX (-50% );
93- } @else if ($dir == ' vertical' ) or ($dir == ' v' ) {
116+ transform : translate3d (-50% , 0 , 0 );
117+ } @else if ($location == top- right) {
118+ top : 0 ;
119+ right : 0 ;
120+ bottom : auto ;
121+ left : auto ;
122+ transform : translate3d (0 , 0 , 0 );
123+ } @else if ($location == middle- left) or ($location == left ) {
124+ top : 50% ;
125+ right : auto ;
126+ bottom : auto ;
127+ left : 0 ;
128+ transform : translate3d (0 , -50% , 0 );
129+ } @else if ($location == middle- right) or ($location == right ) {
94130 top : 50% ;
95- transform : translateY (-50% );
96- } @else if ($dir == ' reset' ) {
131+ right : 0 ;
132+ bottom : auto ;
133+ left : auto ;
134+ transform : translate3d (0 , -50% , 0 );
135+ } @else if ($location == bottom- left) {
136+ top : auto ;
137+ right : auto ;
138+ bottom : 0 ;
139+ left : 0 ;
140+ transform : translate3d (0 , 0 , 0 );
141+ } @else if ($location == bottom- center) or ($location == bottom ) {
142+ top : auto ;
143+ right : auto ;
144+ bottom : 0 ;
145+ left : 50% ;
146+ transform : translate3d (-50% , 0 , 0 );
147+ } @else if ($location == bottom- right) {
97148 top : auto ;
149+ right : 0 ;
150+ bottom : 0 ;
98151 left : auto ;
99- transform : translate ( 0 , 0 );
152+ transform : translate3d ( 0 , 0 , 0 );
100153 } @else {
101154 top : 50% ;
155+ right : auto ;
156+ bottom : auto ;
102157 left : 50% ;
103- transform : translate (-50% , -50% );
158+ transform : translate3d (-50% , -50% , 0 );
104159 }
105160 }
106161}
0 commit comments