-
Notifications
You must be signed in to change notification settings - Fork 39
/
responsive.styl
37 lines (31 loc) · 871 Bytes
/
responsive.styl
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
// simple responsive utility
// pass (min, max) will generate (min-width) and (max-width)
// pass (min) will generate (min-width)
generate-media(args...)
_min_str = 'only screen and (min-width: %s)'
_max_str = ' and (max-width: %s)'
if length(args) == 1
_condition = _min_str % unit(args[0], 'px')
else
_condition = (_min_str % unit(args[0], 'px')) + (_max_str % unit(args[1], 'px'))
@media _condition
{block}
// small device: 0 ~ 600px
sm()
+generate-media(0, $sizes[0])
{block}
gt-sm()
+generate-media($sizes[0])
{block}
// middle device: 600px ~ 960px
md()
+generate-media($sizes[0], $sizes[1])
{block}
// large device: 960px ~ 1200px
lg()
+generate-media($sizes[1], $sizes[2])
{block}
// extra large device: 1200px ~
xl()
+generate-media($sizes[2])
{block}