This repository has been archived by the owner on Apr 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
/
_hacks.scss
477 lines (413 loc) · 9.3 KB
/
_hacks.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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
/* ----------------------------------- //
// CSS Hacks Mixins for Sass
// ----------------------------------- //
How to use:
@include [Mixin_Name]( 'selector', (property: value) )
Example:
@include only_ie9( '.my_element', (color: red) )
@include only_ff28_above( '.my_element', (
background-color: green,
display: flex,
margin: 2em,
))
Tips:
- Use firefox mixins before IE mixins. Sometimes Firefox wants to precess the IE css but it can't and skips it's own CSS!
// ----------------------------------- //
List of Mixins:
only_ff
only_ff2
only_ff2_above
only_ff3_above
only_ff6_above
only_ff16_above
only_ff21_above
only_ff24_above
only_ff25_above
only_ff26_above
only_ff27_above
only_ff28_above
only_ff30_above
only_webkit
only_chrome
only_safari
only_safari9
only_ios
only_safari_no_ios
only_opera9_safari2
only_opera
only_opera11
only_edge
only_ie6
only_ie7
only_ie7_below
only_ie8
only_ie8_below
only_ie9
only_ie9_below
only_ie10_above
only_ie11
only_ie11_above
no_ie6
only_ie9_saf4_above
no_ie_safari6
// ----------------------------------- */
/* ----------------------------------- //
// Firefox CSS Hacks
// ----------------------------------- */
/*--- Only Firefox ---*/
@mixin only_ff($selector, $map){
@-moz-document url-prefix() {
#{$selector} {
@each $property, $value in ($map) {
#{$property}: $value;
}
}
}
}
/*--- Only Firefox 1.5 and Firefox 2 ---*/
@mixin only_ff2($selector, $map){
body:empty #{$selector} {
@each $property, $value in ($map) {
#{$property}: $value;
}
}
}
/*--- Only Firefox ≥ 2 ---*/
@mixin only_ff2_above($selector, $map){
@at-root{
body:last-child & #{$selector} , x:-moz-any-link, x:default{
@each $property, $value in ($map) {
#{$property}: $value;
}
}
}
}
/*--- Only Firefox ≥ 3 ---*/
@mixin only_ff3_above($selector, $map){
@at-root{
& #{$selector} , x:-moz-any-link, x:default{
@each $property, $value in ($map) {
#{$property}: $value;
}
}
}
}
/*--- Only Firefox ≥ 6 ---*/
@mixin only_ff6_above($selector, $map){
_::-moz-progress-bar, body:last-child #{$selector} {
@each $property, $value in ($map) {
#{$property}: $value;
}
}
}
/*--- Only Firefox ≥ 16 ---*/
@mixin only_ff16_above($selector, $map){
@supports (-moz-appearance:meterbar){
#{$selector} {
@each $property, $value in ($map) {
#{$property}: $value;
}
}
}
}
/*--- Only Firefox ≥ 21 ---*/
@mixin only_ff21_above($selector, $map){
_::-moz-range-track, body:last-child #{$selector} {
@each $property, $value in ($map) {
#{$property}: $value;
}
}
}
/*--- Only Firefox ≥ 24 ---*/
@mixin only_ff24_above($selector, $map){
@supports (-moz-appearance:meterbar) and (cursor:zoom-in){
#{$selector} {
@each $property, $value in ($map) {
#{$property}: $value;
}
}
}
}
/*--- Only Firefox ≥ 25 ---*/
@mixin only_ff25_above($selector, $map){
@supports (-moz-appearance:meterbar) and (background-attachment:local){
#{$selector} {
@each $property, $value in ($map) {
#{$property}: $value;
}
}
}
}
/*--- Only Firefox ≥ 26 ---*/
@mixin only_ff26_above($selector, $map){
@supports (-moz-appearance:meterbar) and (image-orientation:90deg){
#{$selector} {
@each $property, $value in ($map) {
#{$property}: $value;
}
}
}
}
/*--- Only Firefox ≥ 27 ---*/
@mixin only_ff27_above($selector, $map){
@supports (-moz-appearance:meterbar) and (all:initial){
#{$selector} {
@each $property, $value in ($map) {
#{$property}: $value;
}
}
}
}
/*--- Only Firefox ≥ 28 ---*/
@mixin only_ff28_above($selector, $map){
@supports (-moz-appearance:meterbar) and (list-style-type:japanese-formal){
#{$selector} {
@each $property, $value in ($map) {
#{$property}: $value;
}
}
}
}
/*--- Only Firefox ≥ 30 ---*/
@mixin only_ff30_above($selector, $map){
@supports (-moz-appearance:meterbar) and (background-blend-mode:difference,normal){
#{$selector} {
@each $property, $value in ($map) {
#{$property}: $value;
}
}
}
}
/* ----------------------------------- //
// Webkit CSS Hacks
// ----------------------------------- */
/*--- Only Webkit (Chrome, Safari, Opera ≥ 14) ---*/
@mixin only_webkit($selector, $map){
.selector:not(*:root) {
#{$selector} {
@each $property, $value in ($map) {
#{$property}: $value;
}
}
}
}
/*--- Only Chrome 28+, Opera ≥ 14 ---*/
@mixin only_chrome($selector, $map){
@media all and (-webkit-min-device-pixel-ratio:0) and (min-resolution: .001dpcm) {
#{$selector} {
@each $property, $value in ($map) {
#{$property}: $value;
}
}
}
}
/*--- Only Safari ≥ 6.1 ---*/
// Dark magic, Don't touch
@function sf_func1($selector, $property) {
@return '@media screen and(min-color-index:0)and(-webkit-min-device-pixel-ratio:0){@media{'+& $selector+'{'+$property;
}
@function sf_func2($value) {
@return $value+'}}}';
}
@mixin only_safari($selector, $map){
@at-root{
@each $property, $value in ($map) {
#{sf_func1($selector, $property)}: #{sf_func2($value)};
}
}
}
/*--- Only Safari ≥ 9 ---*/
@mixin only_safari9($selector, $map){
@supports (overflow:-webkit-marquee) and (justify-content:inherit){
#{$selector} {
@each $property, $value in ($map) {
#{$property}: $value;
}
}
}
}
/*--- Only iOS Safari ≥ 9 ---*/
@mixin only_ios($selector, $map){
@supports (-webkit-text-size-adjust:none) and (not (-ms-accelerator:true)) and (not (-moz-appearance:none)){
#{$selector} {
@each $property, $value in ($map) {
#{$property}: $value;
}
}
}
}
/*--- Only Safari ≥ 9 (Non iOS) ---*/
@mixin only_safari_no_ios($selector, $map){
_:-webkit-full-screen:not(:root:root),#{$selector} {
@each $property, $value in ($map) {
#{$property}: $value;
}
}
}
/*--- Only Opera ≤ 9.27, Safari ≤ 2 ---*/
@mixin only_opera9_safari2($selector, $map){
#{'html:first-child '} #{$selector} {
@each $property, $value in ($map) {
#{$property}: $value;
}
}
}
/* ----------------------------------- //
// Opera CSS Hacks
// ----------------------------------- */
/*--- Only Opera ≥ 9.5 ---*/
@mixin only_opera($selector, $map){
_:-o-prefocus, body:last-child #{$selector} {
@each $property, $value in ($map) {
#{$property}: $value;
}
}
}
/*--- Only Opera ≤ 11 ---*/
@mixin only_opera11($selector, $map){
@media all and (-webkit-min-device-pixel-ratio:10000), not all and (-webkit-min-device-pixel-ratio:0){
#{$selector} {
@each $property, $value in ($map) {
#{$property}: $value;
}
}
}
}
/* ----------------------------------- //
// Edge CSS Hacks
// ----------------------------------- */
@mixin only_edge($selector, $map){
@supports (-ms-accelerator:true) {
#{$selector} {
@each $property, $value in ($map) {
#{$property}: $value;
}
}
}
}
/* ----------------------------------- //
// Internet Explorer CSS Hacks
// ----------------------------------- */
/*--- Only IE ≤ 6 ---*/
@mixin only_ie6($selector, $map){
#{$selector} {
#{'* html '} {
@each $property, $value in ($map) {
#{$property}: $value;
}
}
}
}
/*--- Only IE7 ---*/
@mixin only_ie7($selector, $map){
#{$selector} {
#{'*+html '} {
@each $property, $value in ($map) {
#{$property}: $value;
}
}
}
}
/*--- Only IE ≤ 7 ---*/
@mixin only_ie7_below($selector, $map){
#{$selector} {
#{'*'} {
@each $property, $value in ($map) {
#{$property}: $value;
}
}
}
}
/*--- Only IE8 ---*/
@mixin only_ie8($selector, $map){
#{$selector} {
@each $property, $value in ($map) {
#{$property}: $value+\0#{'/'};
}
}
}
/*--- Only IE ≤ 8 ---*/
@mixin only_ie8_below($selector, $map){
#{$selector} {
@each $property, $value in ($map) {
#{$property}: $value+#{\9};
}
}
}
/*--- Only IE9 ---*/
@mixin only_ie9($selector, $map){
#{$selector} {
@each $property, $value in ($map) {
#{$property}: $value#{\0/IE9};
}
}
}
/*--- Only IE ≤ 9 ---*/
@mixin only_ie9_below($selector, $map){
html[lang=\en] #{$selector} {
@each $property, $value in ($map) {
#{$property}: $value;
}
}
}
/*--- Only IE10 ---*/
@mixin only_ie10_above($selector, $map){
@media all and (-ms-high-contrast:none){
*::-ms-backdrop, #{$selector} {
@each $property, $value in ($map) {
#{$property}: $value;
}
}
}
}
/*--- Only IE ≤ 11 ---*/
@mixin only_ie11($selector, $map){
@media all and (-ms-high-contrast:none){
*::-ms-backdrop, #{$selector} {
@each $property, $value in ($map) {
#{$property}: $value+\0;
}
}
}
}
/*--- Only IE ≥ 11 ---*/
@mixin only_ie11_above($selector, $map){
#{'_:-ms-fullscreen, :root '} #{$selector} {
@each $property, $value in ($map) {
#{$property}: $value;
}
}
}
/*--- Anything but IE6 ---*/
@mixin no_ie6($selector, $map){
#{'html>body '} #{$selector} {
@each $property, $value in ($map) {
#{$property}: $value;
}
}
}
/*--- Only IE ≥ 9, safari4, android ≥ 2.3 ---*/
@mixin only_ie9_saf4_above($selector, $map){
@media screen and (min-width:0\0) {
#{$selector} {
@each $property, $value in ($map) {
#{$property}: $value;
}
}
}
}
/* ----------------------------------- //
// Other CSS Hacks
// ----------------------------------- */
/*--- Everything but IE and Safari ≤ 6 ---*/
@mixin no_ie_safari6($selector, $map){
@media screen {
@media (min-width: 0px) {
#{$selector} {
@each $property, $value in ($map) {
#{$property}: $value;
}
}
}
}
}