forked from drublic/Sass-Mixins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_flexbox.scss
201 lines (194 loc) · 5.03 KB
/
_flexbox.scss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
///
/// Generates flexbox properties for a given element.
///
/// @author romamatusevich
///
/// @link http://caniuse.com/#feat=flexbox caniuse
/// @link http://www.w3.org/TR/css3-flexbox spec
/// @link https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Flexible_boxes MDN
/// @link http://css-tricks.com/snippets/css/a-guide-to-flexbox css-tricks
///
/// @output
/// ```css
/// display: -webkit-box;
/// display: -moz-box;
/// display: -ms-flexbox;
/// display: -webkit-flex;
/// display: flex;
/// ```
///
/// @example
/// .selector {
/// @include x-display-flex;
/// }
///
@mixin x-display-flex {
display: -webkit-box; // Chrome 20-, iOS 6-, Safari 3.1 -6
display: -moz-box; // FF 19-
display: -webkit-flex; // Chrome 21 - 28
display: -ms-flexbox; // IE 10
display: flex; // FF 20+, Chrome 29+, Opera 12.1, 17+
}
///
/// Add flex values to element.
///
/// @param {Arglist} $values
///
/// @output
/// ```css
/// -webkit-box-flex: <values>;
/// -moz-box-flex: <values>;
/// -webkit-flex: <values>;
/// -ms-flex: <values>;
/// flex: <values>;
/// ```
///
/// @example
/// .selector {
/// @include x-flex(1 1 auto);
/// }
///
@mixin x-flex ($values...) {
-webkit-box-flex: $values; // Chrome 20-, iOS 6-, Safari 3.1 - 6
-moz-box-flex: $values; // FF 19-
-webkit-flex: $values; // Chrome 21 - 28
-ms-flex: $values; // IE 10
flex: $values; // FF 20+, Chrome 29+, Opera 12.1, 17+
}
///
/// Add flex order to element.
///
/// @param {Number} $value
///
/// @output
/// ```css
/// -webkit-box-ordinal-group: <value>;
/// -moz-box-ordinal-group: <value>;
/// -ms-flex-order: <value>;
/// -webkit-order: <value>;
/// order: <value>;
/// ```
///
/// @example
/// .selector {
/// @include x-order(1);
/// }
///
@mixin x-order ($value) {
-webkit-box-ordinal-group: $value; // Chrome 20-, iOS 6-, Safari 3.1 - 6
-moz-box-ordinal-group: $value; // FF 19-
-ms-flex-order: $value; // IE 10
-webkit-order: $value; // Chrome 21 - 28
order: $value; // FF 20+, Chrome 29+, Opera 12.1, 17+
}
///
/// Add flex wrap to element.
///
/// @param {String} $value
///
/// @output
/// ```css
/// -webkit-flex-wrap: <value>;
/// -ms-flex-wrap: <value>;
/// flex-wrap: <value>;
/// ```
///
/// @example
/// .selector {
/// @include x-flex-wrap(wrap);
/// }
///
@mixin x-flex-wrap ($value) {
// IE 10
@if $value == nowrap {
-ms-flex-wrap: none;
} @else {
-ms-flex-wrap: $value;
}
-webkit-flex-wrap: $value; // Chrome 20-, iOS 6-, Safari 3.1 - 6
flex-wrap: $value; // FF 28+, Chrome 21+, Opera 12.1, 17+, IE 11
}
///
/// Add flex align-content to element.
///
/// @param {String} $value
///
/// @output
/// ```css
/// -webkit-align-content: <value>;
/// -moz-align-content: <value>;
/// -ms-flex-line-pack: <value>;
/// align-content: <value>;
/// ```
/// @example
/// .selector {
/// @include x-align-content(center);
/// }
///
@mixin x-align-content ($value) {
// IE 10
@if $value == flex-start {
-ms-flex-line-pack: start;
} @else if $value == flex-end {
-ms-flex-line-pack: end;
} @else if $value == space-between {
-ms-flex-line-pack: justify;
} @else if $value == space-around {
-ms-flex-line-pack: distribute;
} @else {
-ms-flex-line-pack: $value;
}
-webkit-align-content: $value; // Chrome 20-, iOS 6-, Safari 3.1 - 6
-moz-align-content: $value; // FF 19-
align-content: $value; // FF 20+, Chrome 21+, Opera 12.1, 17+, IE 11
}
///
/// Add flex direction to element.
///
/// @param {String} $value
///
/// @output
/// ```css
/// -webkit-box-direction: <value>;
/// -moz-box-direction: <value>;
/// -webkit-box-orient: <value>;
/// -moz-box-orient: <value>;
/// -webkit-flex-direction: <value>;
/// -moz-flex-direction: <value>;
/// -ms-flex-direction: <value>;
/// flex-direction: <value>;
/// ```
///
/// @example
/// .selector {
/// @include x-flex-direction(row-reverse);
/// }
///
@mixin x-flex-direction ($value) {
@if $value == row {
-webkit-box-direction: normal;
-moz-box-direction: normal;
-webkit-box-orient: horizontal;
-moz-box-orient: horizontal;
} @else if $value == row-reverse {
-webkit-box-direction: reverse;
-moz-box-direction: reverse;
-webkit-box-orient: horizontal;
-moz-box-orient: horizontal;
} @else if $value == column {
-webkit-box-direction: normal;
-moz-box-direction: normal;
-webkit-box-orient: vertical;
-moz-box-orient: vertical;
} @else if $value == column-reverse {
-webkit-box-direction: reverse;
-moz-box-direction: reverse;
-webkit-box-orient: vertical;
-moz-box-orient: vertical;
}
-webkit-flex-direction: $value;
-moz-flex-direction: $value;
-ms-flex-direction: $value;
flex-direction: $value;
}
//todo: add flex-grow, flex-shrink, flex-basis, flex-flow, align-items, align-self, justify-content mixins