页面自适应

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
72
73
74
<template>
<div id="app">
<router-view/>
</div>
</template>

<script>
export default {
name: 'App',
mounted(){
this.realizeFN()
},
methods:{
realizeFN() {
setTimeout(() => {
window.onresize();
}, 40);
window.onresize = function temp() {
let width = document.body.clientWidth;
let height = document.body.clientHeight;
if (width < 1000) {
return;
}
let scaleVal = width / 1920;
let mark=document.getElementById("login")
if(mark){
return
}
let contain = document.getElementById("app");
if (contain.style) {
contain.style.marginBottom = -(1080 * (1 - scaleVal)) + "px";
contain.style.height=(height/scaleVal-65)+'px'
contain.style.transform = `scale(${scaleVal})`;
}
};
},
},
created(){
}
}
</script>

<style lang="scss">
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
color: #2c3e50;
width: 100%;
height: 100%;
transform-origin: 0 0;
}
::-webkit-scrollbar
{
width: 3px;
height: 5px;
// display: none
}

/*定义滚动条轨道 内阴影+圆角*/
::-webkit-scrollbar-track
{
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
border-radius: 10px;
}

/*定义滑块 内阴影+圆角*/
::-webkit-scrollbar-thumb
{
border-radius: 10px;
-webkit-box-shadow: inset 0 0 6px #15B2CC;
//background-color: #15B2CC;
}
</style>

页面缩放

1
2
3
4
5
6
7
8
function setBodyZoom() {
const width = document.body.clientWidth;
if (width == 1920) {
document.body.style.cssText = 'zoom: 1';
} else {
document.body.style.cssText = 'zoom: ' + width / 1920;
}
}