-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path2-适配.html
50 lines (48 loc) · 1.3 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<script>
(function () {
var metaEl = document.createElement('meta');
var scale = devicePixelRatio;
metaEl.setAttribute('name', 'viewport');
metaEl.setAttribute('content', 'initial-scale=' + (1 / scale) + ', maximum-scale=' + (1 / scale) + ', minimum-scale=' + (1 / scale) + ', user-scalable=no');
document.documentElement.firstElementChild.appendChild(metaEl);
})();
// root em 设置
(function(){
// 375/15
var doc = document.documentElement;
doc.style.fontSize = window.innerWidth/15 + "px";
})();
// 1rem = 1屏幕尺寸的15之一
</script>
<title>Document</title>
<!--
比例单位: vw
-->
<style>
body {
margin: 0;
}
#box {
display: flex;
}
#box div{
width: 6.96rem;
height: 3.6rem;
background: red;
margin: 0 0.2rem;
font-size: .64rem;
}
</style>
</head>
<body>
<div id="box">
<div>尖货抽签</div>
<div>新品日历</div>
</div>
</body>
</html>