html - 视频填充问题

标签 html css

大家好,我现在遇到了一个问题。

我这里有这个页面:http://goo.gl/V0352s

enter image description here

现在我的 youtube 视频被切断了(它甚至没有反应),我试图弄清楚可能是什么问题以及如何使用 CSS 解决它。我有 ff: HTML:

    <div style="width: 46%; float:left;height: 299px;">
    <iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/h8NChiwfkFs?rel=0&amp;controls=0&amp;showinfo=0" frameborder="0" allowfullscreen=""></iframe>
    </div>

<div style="float: right; width: 46%">
<h5>Description:</h5>
<p>Promotional Video for iLiveAccountable. A local life coaching and training company. Owned by Tony Beatty and Michael Gardner.</p>
<h5>Company</h5>
<p>iLiveAccountable</p>
<h5>Project Link</h5>
<p><a href="https://goo.gl/JZ0Hfw" target="_blank">https://goo.gl/JZ0Hfw</a>
</p></div>

您可以尝试在 Chrome 上右击 inspect element 来实时查看。

提前感谢您的帮助!

最佳答案

添加此 CSS:

@media (min-width: 768px) {
    .postid-146 iframe {
        height: 31.5vw;
        max-height: 315px;
    }
}

<罢工>

在多次尝试以响应方式使这项工作失败后,我制作了一个脚本,根据其集合 width 调整 iframe 的大小。和 height属性,以及实际的 width :

jQuery(document).ready(function($) {
  $(window).on('load resize', function() {
    $('iframe').each(function() {
      $(this).css({
        'height': ($(this).attr('height') * $(this).width() / $(this).attr('width')) + 'px'
      });
    })
  });
});

关于html - 视频填充问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34714072/

相关文章:

javascript - Identity Toolkit 无法工作 - 错误代码 : Bad response from IDP

javascript - 图像不通过 jquery 显示

html - 奇怪的 CSS :after pseudoselector issue in Chrome alone

css - 使用 CSS 进行页面布局 - 这是完成此布局的最佳方式吗?

javascript - 用户滚动按钮时如何滑动特定的 Web 部件(HTML)

jquery - WordPress 中的 HTML5 PushState()

javascript - 如何通过索引选择表格单元格?

html - 如何在使用 float 定位的多列设计中使 div 的高度相等?

html - 数据表内的 CSS primefaces panelgrid

JavaScript 导致所有子菜单成为一个链接而不是移动设备上的单个链接(错误)