html - Youtube 嵌入不适用于 % 参数

标签 html css youtube embed

好吧,我无法将嵌入的 youtube-clip 设为 % 宽度/高度。尝试创建一个无论分辨率如何都一样的网站。

如何让他们使用 % 而不是 px?

<table id="tableframsida" align="center" border="0" height="80%">  
    <tr>
        <td height="100%">
            <h2>HeatoN explains how to think when you're creating tactics</h2>
        </td>
        <td height="100%">
            <iframe width="100%" height="100%" src="http://www.youtube.com/embed/UTdFMBReXBw" frameborder="0" allowfullscreen></iframe>

</table>

最佳答案

关于您想要的布局的信息很少,我建议您可以调整此 HTML/CSS 以满足您的要求。

  • 我删除了 iframe 的 width=100%height=100%,这是 iframe 的默认值
  • 我将表格显示更改为经典的包装 div + 元素和 display:inline-block

HTML

<div class="videoWrapper">
    <h2>HeatoN explains how to think when you're creating tactics</h2>
    <iframe  src="http://www.youtube.com/embed/UTdFMBReXBw" frameborder="0" allowfullscreen></iframe>
</div>

CSS

.videoWrapper{
    height:600px;
}

.videoWrapper h2, .videoWrapper iframe{
    display:inline-block;
}
.videoWrapper h2{
    word-wrap:;
    width:25%;
}
.videoWrapper iframe{
    width:70%;
}

Fiddle

关于html - Youtube 嵌入不适用于 % 参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16265178/

相关文章:

javascript - YouTube API : How to grab video ID? JQuery/Json

javascript - 单选按钮选择的值; 3个选项的选择

javascript - 如何从选择器中排除具有属性的元素,无论其值如何

html - 拨动开关按钮 - 如何设置响应式测量?

html - 溢出 : Scroll doesn’t work

css - 与损坏的 Bootstrap 对齐

javascript - 在 Javascript 中更新/编辑表

java - 如何使用 JavaMail 发送 html 电子邮件?

javascript - YouTube将http重定向到https并使用Flash Player代替HTML5

ruby-on-rails - 通过youtube_it gem 查询YouTube上的可嵌入视频