Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 背景视频缩放_Css_Video_Background - Fatal编程技术网

Css 背景视频缩放

Css 背景视频缩放,css,video,background,Css,Video,Background,尝试在HTML5中创建背景视频。下面的代码无意中缩放了显示 CSS: 我做了大量的测试,估计变焦率在10%-20%之间。相信我,我已经考虑了纵横比,但仍然不明白为什么它会增加视频的规模 显然,这破坏了视频的整体质量,使其看起来更加像素化 以下是答案 .bgvid3 { object-fit: cover; object-position: center center; position: absolute; left: 0; top: 0; wid

尝试在HTML5中创建背景视频。下面的代码无意中缩放了显示

CSS:

我做了大量的测试,估计变焦率在10%-20%之间。相信我,我已经考虑了纵横比,但仍然不明白为什么它会增加视频的规模

显然,这破坏了视频的整体质量,使其看起来更加像素化

以下是答案

.bgvid3 {
    object-fit: cover;
    object-position: center center;
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
}

不知道为什么会这样,但确实如此(你会认为宽度和高度100%时会有一些方面的问题)。不进行缩放,可在所有屏幕上工作。

您还可以为IE添加此代码。@media all和(-ms高对比度:无)、(-ms高对比度:活动){/*仅IE*/#bgvid2{位置:绝对;顶部:20%;左侧:50%;最小宽度:100%;最小高度:100vh;宽度:自动;高度:自动;-ms变换:平移(-50%,-20%);-moz转换:转换(-50%,-20%);-webkit转换:转换(-50%,-20%);-o转换:转换(-50%,-20%);转换:转换(-50%,-20%);}
.bgvid3 {
    object-fit: cover;
    object-position: center center;
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
}