-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
55 lines (52 loc) · 1.17 KB
/
index.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
53
54
55
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>appdemo</title>
<style>
html,body{
width: 100%;
overflow:scroll;
height: 100%;
}
*{
margin: 0;
padding: 0;
}
a{
text-decoration: none;
}
li{
list-style: none;
}
</style>
</head>
<body>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
<script>
font();
window.onresize = function(){
font();
}
function font()
{
var clientWidth = document.documentElement.clientWidth || window.innerWidth; // 获取当前屏幕宽度
//console.log(clientWidth);
if(clientWidth>650)
{
document.querySelector('html').style.fontSize = 100 + 'px';
}
else if(clientWidth<350)
{
document.querySelector('html').style.fontSize = 50 + 'px';
}
else{
var size = Math.floor( clientWidth / 650 * 100 ); // 根据宽度计算根节点字体大小
document.querySelector('html').style.fontSize = size + 'px';
}
}
</script>
</html>