IE的对象适合替代方法,用于宽度和设置高度为100%的视频 [英] object-fit alternative for IE for a video with 100% width and set height
问题描述
我有一个适合放在容器中的视频,其宽度为100%,固定高度为750px.该视频已设置为适合对象:填充",除了您认为是IE之外,它在所有浏览器上均能完美运行.我了解IE不支持对象适配,并且想知道是否有人知道解决方法吗?
I have a video that fits in a container and has a width of 100% and a fixed height of 750px. The video has been set to object-fit: fill, and this works perfectly on all browser apart from..... you guessed it IE! I understand that object-fit is not supported in IE and wonder if anyone knows a workaround?
#mainContainer {
width: 100%;
height: 750px;
border-bottom: solid 4px #9B51E0;
position: relative;
}
#mainVideo {
width: 100%;
height: 750px;
object-fit: fill;
position: absolute;
opacity: 0.85;
}
<div id="mainContainer">
<video id="mainVideo" autoplay loop>
<source src="video.mp4">
</video>
</div>
推荐答案
一点都不奇怪;-) IE不支持object-fit属性,但是为此提供了polyfills. 我一直使用这个: https://github.com/bfred-it/object-适合图像
Not surprising at all ;-) IE doesn't support object-fit property, but there are polyfills for that. I always use this one: https://github.com/bfred-it/object-fit-images
编辑: 对于视频 https://github.com/constancecchen/object-fit-polyfill
这篇关于IE的对象适合替代方法,用于宽度和设置高度为100%的视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!