媒体查询media

本文最后更新于:2023年3月16日 下午

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
@media all and (min-width: 400px) {
.box {
width: 400px;
height: 400px;
background: red;
}
}
@media all and (max-width: 399px) {
.box {
width: 200px;
height: 200px;
background: blue;
}
}
/*
all 媒体类型

and 关键字( not 和only)

(min-width: 400px) 媒体特性
orientation:横竖屏切换

landscape 横屏

portrait 竖屏

PC IPAD 手机
1024 400 220
*/

@media all and (min-width:1200px) {
.box {
width: 1200px;
height: 500px;
background: red;
}
}

@media all and (min-width:1024px) and (max-width:1199px) {
.box {
width: 1024px;
height: 400px;
background: blue;
}
}
@media all and (min-width:400px) and (max-width:1023px) {
.box {
width: 400px;
height: 300px;
background: yellow;
}
}
@media all and (min-width:220px) and (max-width:399px) {
.box {
width: 200px;
height: 200px;
background: pink;
}
}
@media all and (max-width:219px) {
.box {
width: 100px;
height: 100px;
background: #000;
}
}
/*
min-width:1200px 分辨率 最小在1200 之上包括1200

max-width:1024px 分辨率在1024以下 包括1024
*/

媒体查询media
https://seven3.site/css/媒体查询media/
作者
Seven3s
发布于
2015年3月15日
许可协议