-
Notifications
You must be signed in to change notification settings - Fork 1
/
10-media-queries.scss
91 lines (68 loc) · 2 KB
/
10-media-queries.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
// MEDIA QUERIES IN SASS 3.2
// Ref: http://thesassway.com/intermediate/responsive-web-design-in-sass-using-media-queries-in-sass-32
// EXAMPLE 1: VARIABLES IN QUERIES
// =================================================
$break-small: 320px;
$break-large: 1200px;
.profile-pic {
float: left;
width: 250px;
@media screen and (max-width: $break-small) {
width: 100px;
float: none;
}
@media screen and (min-width: $break-large) {
float: right;
}
}
// css output:
profile-pic { float: left; width: 250px; }
@media screen and (max-width: 320px) {
.profile-pic { width: 100px; float: none; }
}
@media screen and (min-width: 1200px) {
.profile-pic { float: right; }
}
// EXAMPLE 2: VARIABLES AS FULL QUERY
// =================================================
$information-phone: "only screen and (max-width : 320px)";
@media #{$information-phone} {
background: red;
}
// css output:
@media only screen and (max-width : 320px) {
background: red;
}
// EXAMPLE 3: ALLOWS BLOCKS AS MIXIN PARAMETERS
// =================================================
$break-small: 320px;
$break-large: 1024px;
@mixin respond-to($media) {
@if $media == handhelds {
@media only screen and (max-width: $break-small) { @content; }
}
@else if $media == medium-screens {
@media only screen and (min-width: $break-small + 1) and (max-width: $break-large - 1) { @content; }
}
@else if $media == wide-screens {
@media only screen and (min-width: $break-large) { @content; }
}
}
.profile-pic {
float: left;
width: 250px;
@include respond-to(handhelds) { width: 100% ;}
@include respond-to(medium-screens) { width: 125px; }
@include respond-to(wide-screens) { float: none; }
}
// css output:
.profile-pic { float: left; width: 250px; }
@media only screen and (max-width: 320px) {
.profile-pic { width: 100%; }
}
@media only screen and (min-width: 321px) and (max-width: 1023px) {
.profile-pic { width: 125px; }
}
@media only screen and (min-width: 1024px) {
.profile-pic { float: none; }
}