赞
踩
- <!-- 数据大屏展示内容区域 -->
- <div class="container">
- <div class="screen" ref="screen">
-
- </div>
- </div>
screen.value.style.transform = `scale(${getScale()}) translate(-50%,-50%)`
- //获取数据大屏展示内容盒子的DOM元素
- let screen = ref()
- onMounted(() => {
- screen.value.style.transform = `scale(${getScale()}) translate(-50%,-50%)`
- })
- //定义大屏缩放比例
- function getScale(w = 1920, h = 1080) {
- const ww = window.innerWidth / w
- const wh = window.innerHeight / h
- return ww < wh ? ww : wh
- }
- //监听视口变化
- window.onresize = () => {
- screen.value.style.transform = `scale(${getScale()}) translate(-50%,-50%)`
- }
- .container {
- width: 100vw;
- height: 100vh;
- background: url("./images/bg.png") no-repeat;
- background-size: cover;
- }
- .screen {
- position: fixed;
- width: 1920px;
- height: 1080px;
- left: 50%;
- top: 50%;
- transform-origin: left top;
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。