有没有办法将我放在我的 html 页面背景中的视频定位并使其重复,就像我使用background-*
css 属性对图像/gif 所做的那样?我确信这在当前版本的 CSS 中是不可能的,但也许有一种方法可以用 JavaScript 做到这一点。该视频最初是 gif,而我正在尝试使用 gif 进行操作,但我将其转换为 webm 和 mp4 以提高加载性能并节省带宽。下面是如果我的视频是 gif 我会做什么的代码,然后是我目前拥有的代码并且想要复制“Video as Gif”的代码。
视频作为 Gif
body {
background: url('https://media3.giphy.com/media/KZFrf9JusXzmpnPsT6/giphy.gif?cid=ecf05e47nlo6zhk89xm58aaee38kzq5tddoko195kri6hv0e&rid=giphy.gif') center center;
background-repeat: repeat;
position: relative;
background-size: auto;
overflow: hidden;
width: 100%;
}
<html>
<body>
</body>
</html>
GIF 视频
#video-background {
top: 0;
left: 0;
position: absolute;
width: 100%;
height: 100%;
background-repeat: repeat;
overflow: hidden;
}
<div id="video-background">
<video aria-hidden="true" playsinline="" autoplay="" muted="" loop=""> <source src="//starlink.ua/media/mod_starlink/car-blur.webm" type="video/webm"> <source src="//starlink.ua/media/mod_starlink/car-blur.mp4" type="video/mp4"></video>
</div>