当前位置:网站首页>背景视频铺满盒子

背景视频铺满盒子

2022-08-10 17:39:00 凡小多

使用object-fit: cover可以铺满盒子,盒子高度需100%,

video {
    
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  height: 100%;	// height: 100vh;
  -o-object-fit: cover;
  object-fit: cover;	// 自适应铺满内容
  z-index: -10;	// 置于底部 source {
    
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
  }
}

但是给video盒子设置具体px高度,则在ie浏览器有兼容问题,会在两边出现间隙

原网站

版权声明
本文为[凡小多]所创,转载请带上原文链接,感谢
https://blog.csdn.net/wgh4318/article/details/126221597