-
Notifications
You must be signed in to change notification settings - Fork 159
/
_media-queries.scss
225 lines (185 loc) · 4.61 KB
/
_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
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
// Author: Rafal Bromirski
// www: http://rafalbromirski.com/
// github: http://github.com/rafalbromirski/sass-mediaqueries
//
// Licensed under a MIT License
//
// Version:
// 1.6.1
// --- generator ---------------------------------------------------------------
@mixin mq($args...) {
$media-type: 'only screen';
$media-type-key: 'media-type';
$args: keywords($args);
$expr: '';
@if map-has-key($args, $media-type-key) {
$media-type: map-get($args, $media-type-key);
$args: map-remove($args, $media-type-key);
}
@each $key, $value in $args {
@if $value {
$expr: "#{$expr} and (#{$key}: #{$value})";
}
}
@media #{$media-type} #{$expr} {
@content;
}
}
// --- screen ------------------------------------------------------------------
@mixin screen($min, $max, $orientation: false) {
@include mq($min-width: $min, $max-width: $max, $orientation: $orientation) {
@content;
}
}
@mixin max-screen($max) {
@include mq($max-width: $max) {
@content;
}
}
@mixin min-screen($min) {
@include mq($min-width: $min) {
@content;
}
}
@mixin screen-height($min, $max, $orientation: false) {
@include mq($min-height: $min, $max-height: $max, $orientation: $orientation) {
@content;
}
}
@mixin max-screen-height($max) {
@include mq($max-height: $max) {
@content;
}
}
@mixin min-screen-height($min) {
@include mq($min-height: $min) {
@content;
}
}
// --- hdpi --------------------------------------------------------------------
@mixin hdpi($ratio: 1.3) {
@media only screen and (-webkit-min-device-pixel-ratio: $ratio),
only screen and (min-resolution: #{round($ratio*96)}dpi) {
@content;
}
}
// --- hdtv --------------------------------------------------------------------
@mixin hdtv($standard: '1080') {
$min-width: false;
$min-height: false;
$standards: ('720p', 1280px, 720px)
('1080', 1920px, 1080px)
('2K', 2048px, 1080px)
('4K', 4096px, 2160px);
@each $s in $standards {
@if $standard == nth($s, 1) {
$min-width: nth($s, 2);
$min-height: nth($s, 3);
}
}
@include mq(
$min-device-width: $min-width,
$min-device-height: $min-height,
$min-width: $min-width,
$min-height: $min-height
) {
@content;
}
}
// --- iphone4 -----------------------------------------------------------------
@mixin iphone4($orientation: false) {
$min: 320px;
$max: 480px;
$pixel-ratio: 2;
$aspect-ratio: '2/3';
@include mq(
$min-device-width: $min,
$max-device-width: $max,
$orientation: $orientation,
$device-aspect-ratio: $aspect-ratio,
$-webkit-device-pixel-ratio: $pixel-ratio
) {
@content;
}
}
// --- iphone5 -----------------------------------------------------------------
@mixin iphone5($orientation: false) {
$min: 320px;
$max: 568px;
$pixel-ratio: 2;
$aspect-ratio: '40/71';
@include mq(
$min-device-width: $min,
$max-device-width: $max,
$orientation: $orientation,
$device-aspect-ratio: $aspect-ratio,
$-webkit-device-pixel-ratio: $pixel-ratio
) {
@content;
}
}
// --- iphone6 -----------------------------------------------------------------
@mixin iphone6($orientation: false) {
$min: 375px;
$max: 667px;
$pixel-ratio: 2;
@include mq(
$min-device-width: $min,
$max-device-width: $max,
$orientation: $orientation,
$-webkit-device-pixel-ratio: $pixel-ratio
) {
@content;
}
}
// --- iphone6 plus ------------------------------------------------------------
@mixin iphone6-plus($orientation: false) {
$min: 414px;
$max: 736px;
$pixel-ratio: 3;
@include mq(
$min-device-width: $min,
$max-device-width: $max,
$orientation: $orientation,
$-webkit-device-pixel-ratio: $pixel-ratio
) {
@content;
}
}
// --- ipad (all) --------------------------------------------------------------
@mixin ipad($orientation: false) {
$min: 768px;
$max: 1024px;
@include mq(
$min-device-width: $min,
$max-device-width: $max,
$orientation: $orientation
) {
@content;
}
}
// --- ipad-retina -------------------------------------------------------------
@mixin ipad-retina($orientation: false) {
$min: 768px;
$max: 1024px;
$pixel-ratio: 2;
@include mq(
$min-device-width: $min,
$max-device-width: $max,
$orientation: $orientation,
$-webkit-device-pixel-ratio: $pixel-ratio
) {
@content;
}
}
// --- orientation -------------------------------------------------------------
@mixin landscape() {
@include mq($orientation: landscape) {
@content;
}
}
@mixin portrait() {
@include mq($orientation: portrait) {
@content;
}
}