bootstrap 5响应式iframe保持16-9比率

问题描述 投票:0回答:3

我已经阅读了许多帖子,并尝试了所有内容以使iframe响应迅速并保持16-9的比率...这还不错,但是视频仍在YouTube框架中裁剪。 Bootstrap 5的技巧是什么?

<div class="embed-responsive embed-responsive-16by9" style="width:800px; height:450px"> <iframe class="embed-responsive" title="YouTube video player" src="{{ $image['image']['url'] }}" frameborder="0" allowfullscreen="" width="100%" height="100%"></iframe> </div>

Bootstrap网站上的文档遇到了相同的问题,这是:
iframe bootstrap-5 responsive-images
3个回答
16
投票

但这不起作用,高度被忽略了。

I在MD Bootstrap文档上找到了一个解决方案:
<div class="ratio ratio-16x9">
<iframe src="https://www.youtube.com/embed/vlDzYIIOYmM" title="YouTube video" allowfullscreen></iframe>
</div>

MD引导程序:嵌入

如果您添加高度和宽度
(如果您添加高度和宽度),对我来说是非常适合我的工作
<div class="ratio ratio-16x9"> <iframe src="https://www.youtube.com/embed/vlDzYIIOYmM" title="YouTube video" style="max-width: 100%;height: 100%;" allowfullscreen></iframe> </div>

也可以在Bootstrap 5文档中找到此信息:

https://getBootstrap.com/docs/5.0/helpers/ratio/

https://getBootstrap.com/docs/5.0/migration/
  • this Soluction是Bootstrap 5中唯一工作的:

6
投票
<div class="col-12 col-md-8 offset-md-2 col-lg-8 offset-lg-2"> <div class="ratio ratio-16x9 text-center mt-4 mb-4 "> <iframe class="embed-responsive-item" src="https://www.youtube.com/embed/DTpvdyzxQWE?controls=0" style="max-width: 100%;height: 100%;" allowfullscreen></iframe> </div> </div>

不要问我为什么,但是在一些测试中,添加了较旧的Bootstrap CSS在使用JNIC发布的Bootstrap格式时为我做了一个技巧:


0
投票
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous"> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">

该版本应该起作用。
<div class="embed-responsive embed-responsive-16by9"> <iframe class="embed-responsive-item" title="YouTube video player" src="https://www.youtube.com/watch?v=jNQXAC9IVRw" allowfullscreen=""></iframe> </div>

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.