gpt4 book ai didi

javascript - 无法根据设备自动调整YouTube播放器的大小

转载 作者:行者123 更新时间:2023-12-03 06:19:57 25 4
gpt4 key购买 nike

我是html,css,js等的新手,即时通讯试图自动调整youtube窗口的大小以适合设备的屏幕,但对我不起作用。
我已经尝试了本网站提供的许多解决方案,但似乎没有任何效果。
这是视频代码的一部分

的HTML

 <div class="wrapper">
<div class="h-iframe">
<iframe class="center-block" src="https://www.youtube.com/embed/Npa-z3P1FTY" frameborder="0" allowfullscreen></iframe>
</div>
</div>

的CSS

.h_iframe iframe {
position:absolute;
top:0;
left:0;
width:100%;
height:100%;
}

.center-block {
display: block;
margin-left: auto;
margin-right: auto;
}

.wrapper {
position: relative;
width: 100%;
}

最佳答案

这就是我用的。

/* Flexible iFrame */

.flexible-container {
position: relative;
padding-bottom: 56.25%;
padding-top: 30px;
height: 0;
overflow: hidden;
}

.flexible-container iframe,
.flexible-container object,
.flexible-container embed {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
<!-- Responsive iFrame -->
<div class="flexible-container">
<iframe src="https://b922bde52f23a8481830-83cb7d8d544f653b52d1a1621f05ea9d.ssl.cf3.rackcdn.com/video/landingpage.mp4" frameborder="0" style="border:0"></iframe>
</div>


live link

关于javascript - 无法根据设备自动调整YouTube播放器的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37219539/

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