iframe - bootstrap 5 响应式 iframe 保持 16-9 的比例
问题描述
我已经阅读了很多帖子并尝试了一切以使 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>
解决方案
遇到了同样的问题,引导站点上的文档说:
<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>
但这不起作用,高度被忽略了。
我在 MD Bootstrap 文档上找到了一个解决方案:
<div class="ratio ratio-16x9">
<iframe src="https://www.youtube.com/embed/vlDzYIIOYmM" title="YouTube video" allowfullscreen></iframe>
</div>
如果您添加高度和宽度,在 BS5 上非常适合我
<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 文档中找到:
推荐阅读
- ios - 在 Swift 中的现有图层下方插入子图层时出现问题?
- google-apps-script - 如何使用新 Google 电子表格的数据填充特定工作表中的单元格
- makefile - 带有单独目录树中的对象的 Makefile
- git - 从开发分支检查最新提交的 Git 命令
- react-native - 播放 youtube 嵌入视频时反应原生 webview 崩溃
- docker - Docker化的反向代理
- c# - gmail不再发送电子邮件
- typescript - 打字稿:将类型定义为除函数之外的任何类型
- kotlin - 如何结合 JUnit4 @RunWith(Parameterized.class) 和 JUnit5 @ParameterizedTest
- asp.net - 无法从 Angular 将文件作为 FormData 上传到 ASP.net