-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.php
62 lines (50 loc) · 1.45 KB
/
test.php
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js"></script>
<style>
@media (orientation:landscape) {
.col{
border:1px solid #00f;
}
}
@media (orientation:portrait) {
.col{
border:1px solid #f00;
}
}
</style>
</head>
<body>
<div class="row">
<div class="col col-sm-6">
HeJ
</div>
<div class="col col-sm-6">
HeJ
</div>
</div>
<script>
function checkOrientation(){
if (window.matchMedia("(orientation: portrait)").matches) {
$(".col").addClass("col-sm-12");
$(".col").removeClass("col-sm-6");
}
if (window.matchMedia("(orientation: landscape)").matches) {
$(".col").addClass("col-sm-6");
$(".col").removeClass("col-sm-12");
}
}
checkOrientation();
// Listen for orientation changes
window.addEventListener("orientationchange", function() {
checkOrientation();
}, false);
</script>
</body>
</html>