大屏页面适应不同分辨率的屏幕 transform
大屏自适应
·
思路:
设计稿为1920 * 1080,为兼容大部分PC显示器,对非1920分辨率的页面进行等比缩放
// 页面加载,缩放比例
scaleFunc() {
this.scaleSize = document.body.clientWidth / 1903
let scaleSize = this.scaleSize
this.$refs["appRef"].style.transform = `scale(${scaleSize})`
},
mounted() {
this.scaleFunc()
}
<div class="dashboard-wrap">
<div class="app-container dashboard" id="index" ref="appRef">
...
</div>
</div>
//样式
.dashboard-wrap {
width: 100%;
height: 100vh; // 要写高度,否则会显示缩放前的高度,分辨率小的时候,下面会有空白
.dashboard {
width: 1903px; //滚动条宽度为17px,所以为1903px
padding: 0;
background: #011246;
transform-origin:0 0; //默认是垂直水平居中的,所以要以左上角为origin
}
}
更多推荐
所有评论(0)