gpt4 book ai didi

jquery - 如何让视频全屏

转载 作者:行者123 更新时间:2023-11-28 16:31:28 26 4
gpt4 key购买 nike

我想全屏吗?

我的旧代码是这样的

    <div id="test"></div>


<div id="body">lorem ipusm dolor sue lorem ipusm dolor sue lorem ipusm dolor sue lorem ipusm dolor sue lorem ipusm dolor sue lorem ipusm dolor sue</div>


with css

#test{
width: 100%;
height: 100vh;
background: url('https://placeholdit.imgix.net/~text?txtsize=33&txt=350%C3%97150&w=350&h=150') no-repeat center center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
background-size: 100% 100%;
}

现在我想用视频改变图像但是全屏所以我这样改变

<div id="video">
<div class="embed-responsive embed-responsive-16by9">
<video id="video1">
<source src="video/inspiration-1.mp4" type="video/mp4">
</video>
</div>
</div>

<div id="body">lorem ipusm dolor sue lorem ipusm dolor sue lorem ipusm dolor sue lorem ipusm dolor sue lorem ipusm dolor sue lorem ipusm dolor sue</div>

如何使用 css 使其全屏显示,因为当我尝试运行此代码时它会像 padding-top 一样离开??

这是我的作品 https://jsfiddle.net/f0Lcdfrt/4/

最佳答案

您可以通过这种方式激活全屏模式

var elem = document.getElementById("video1");
if (elem.requestFullscreen) {
elem.requestFullscreen();
} else if (elem.msRequestFullscreen) {
elem.msRequestFullscreen();
} else if (elem.mozRequestFullScreen) {
elem.mozRequestFullScreen();
} else if (elem.webkitRequestFullscreen) {
elem.webkitRequestFullscreen();
}

有关更多信息,请参阅 MDN 文档 https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API

关于jquery - 如何让视频全屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36093878/

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