vw vh减去px计算,根据flex进行播放窗口的2 4 6 9宫格布局
根据CSS3规范,视口单位主要包括:
1.vw:1vw等于视口宽度的1%。
2.vh:1vh等于视口高度的1%。
全屏布局需要去掉滚动条:
body::-webkit-scrollbar {
/滚动条整体样式/
width: 0px;
/高宽分别对应横竖滚动条的尺寸/
/* height: 1px; */
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="divport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
}
.app {
display: flex;
flex-direction: row;
flex-wrap: wrap;
width: 100%;
height: 100%;
}
body::-webkit-scrollbar {
/*滚动条整体样式*/
width: 0px;
/*高宽分别对应横竖滚动条的尺寸*/
/* height: 1px; */
}
</style>
</style>
</head>
<body>
<div class="app">
<iframe :src='item' :style='itemStyle' v-for="(item, index) in list" :key='index'>
</iframe>
</div>
</body>
<script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.9/vue.js"></script>
<script>
new Vue({
el: '.app',
data: {
list: ['001507', '001505', '001503', '001501', '001499'], //,'001505','001501','001499'
itemStyle: {
width: '',
height: '',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
flexDirection: 'column',
border: '1px solid #ccc',
overFlow: 'hidden'
},
},
mounted() {
this.getWindow()
},
methods: {
getWindow() {
this.list.length > 9 ? this.list.length = 9 : this.list.length
this.list = this.list.map(item =>
`http://qingdao.czczh.cn/pc/main/sub/car_video/index.html?camindex=${item}&server=1`)
let len = this.list.length
if (len == 1) {
//vw-px vh-px
this.itemStyle.width = 'calc(100vw - 4px)'
this.itemStyle.height = 'calc(100vh - 4px)'
} else if (len > 1 && len <= 2) {
this.itemStyle.width = 'calc(50vw - 2px)'
this.itemStyle.height = 'calc(100vh - 2px)'
} else if (len > 2 && len <= 4) {
this.itemStyle.width = 'calc(50vw - 2px)'
this.itemStyle.height = 'calc(50vh - 2px)'
} else if (len > 4 && len <= 6) {
this.itemStyle.width = 'calc(33.3vw - 2px)'
this.itemStyle.height = 'calc(50vh - 2px)'
} else if (len > 6 && len <= 9) {
this.itemStyle.width = 'calc(33.3vw - 4px)'
this.itemStyle.height = 'calc(33.3vh - 4px)'
}
},
}
})
</script>
</html>
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具