gpt4 book ai didi

css - Youtube 视频作为具有最小宽度和最小高度的完整背景

转载 作者:行者123 更新时间:2023-11-28 06:52:00 24 4
gpt4 key购买 nike

我想要一个全尺寸的背景 YouTube 视频。我用了following example对于 html5 视频,它有效。

我想要相同的、可调整大小的背景视频,但不幸的是两边都出现黑条。

针对 html5 视频的解决方案是以下代码段:

min-width: 100%;
min-height: 100%;
width: auto;
height: auto;
position: aboslute;

youtube 视频有什么问题?获得相同结果的最佳方法是什么?

body {
margin: 0;
padding: 0;
background: #333;
background-attachment: fixed;
background-size: cover;
}

#video-background {
position: fixed;
right: 0;
bottom: 0;
min-width: 100%;
min-height: 100%;
width: auto;
height: auto;
z-index: -100;
}

article {

position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
border: 10px solid rgba(255, 255, 255, 0.5);
margin: 10px;
}

h1 {
position: absolute;
top: 60%;
width: 100%;
font-size: 36px;
letter-spacing: 3px;
color: #fff;
font-family: Oswald, sans-serif;
text-align: center;
}
<article>

<h1>GROSS DESIGN co.</h1>
</article>

<video autoplay loop id="video-background" muted>
<source src="http://beta.mattgrossdesign.com/sites/default/files/wood%20autumn-HD.mp4" type="video/mp4">
</video>

最佳答案

您可以使用 Jquery 尝试另一种方法;它可以让你的 youtube 视频根据浏览器视口(viewport)自动调整大小。将您的内容放入 DIV 并将其用作容器。

Original Tutorial

关于css - Youtube 视频作为具有最小宽度和最小高度的完整背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33718986/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com