-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path2.html
52 lines (47 loc) · 1.26 KB
/
2.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"/>
<style type="text/css">
* {
margin: 0;
padding: 0;
}
html, body {
width: 100%;
height: 100%;
}
@media all and (orientation: portrait) {
/*竖屏*/
body {
background: #FFCF78;
}
}
@media all and (orientation: landscape) {
/*横屏*/
body {
background: #1c90f2;
}
}
</style>
</head>
<body>
<script type="text/javascript">
//->HTML5/JS/CSS3只能检测横竖屏,不能禁止横竖屏
var supportsOrientationChange = "onorientationchange" in window,
orientationEvent = supportsOrientationChange ? "orientationchange" : "resize";
window.addEventListener(orientationEvent, function () {
if (supportsOrientationChange) {
if (Math.abs(window.orientation) === 90) {
//->横屏
} else {
//->竖屏
}
}
}, false);
</script>
</body>
</html>