(vue)整个页面添加背景视频
App.vue
<template>
<div id="app" :class="[platform]">
<video src="./assets/images/top/bg-video-711.mp4" autoplay muted loop class="bg"></video>
<router-view />
</div>
</template>
css
<style lang="less">
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
// text-align: center;
color: #2c3e50;
}
video.bg {
position: fixed;
/* 视频绝对定位 */
top: 0;
left: 0;
width: 100%;
/* 宽度占据整个屏幕 */
height: 100%;
/* 高度占据整个屏幕 */
object-fit: fill;
/* 填满整个容器,可能会裁剪视频 */
}
.bg {
width: 100%;
height: 100%;
}
...
</style>