(vue) ページ全体に背景ビデオを追加します

(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>

おすすめ

転載: blog.csdn.net/qq_44754635/article/details/131654864