【发布时间】:2020-01-31 01:36:14
【问题描述】:
我正在尝试在保持宽高比的同时调整嵌入视频的大小。 (在这种情况下是 16:9)
我在这个网站上找到了解决方案:https://css-tricks.com/NetMag/FluidWidthVideo/Article-FluidWidthVideo.php
如您所见,视频(我使用的是 vimeo)在用户调整窗口大小的同时很好地调整了大小。但是我无法让它与这个 Javascript 代码一起工作。 我熟悉 HTML 和 CSS,但我是 Javascript 的菜鸟。
这是我的 HTML,我通常会使用外部 CSS,但在这里我复制了我正在尝试做的事情并对其进行了简化:
<!DOCTYPE html>
<html lang="EN" style="height: 100%;">
<head>
<meta name="viewport" content="width: device-width; initial-size: 1.0;">
<style>
body{
background-color: darkolivegreen;
}
table{
width: max-content;
height: max-content;
position: absolute;
}
iframe{
width: 450px;
height: 253.13px;
}
#table1{
left: 4.2vw;
top: 33vh;
}
#table2{
right: 4.2vw;
top: 33vh;
}
</style>
</head>
<body>
<table id="table1">
<tr>
<td>
<iframe src="https://player.vimeo.com/video/385145267?color=ffffff" width="640" height="360" frameborder="0" allow="autoplay; fullscreen" allowfullscreen></iframe>
</td>
</tr>
</table>
<table id="table2">
<tr>
<td>
<iframe src="https://player.vimeo.com/video/385145267?color=ffffff" width="640" height="360" frameborder="0" allow="autoplay; fullscreen" allowfullscreen></iframe>
</td>
</tr>
</table>
</body>
</html>
【问题讨论】:
-
停止使用表格 - 这是老派。请改用嵌套的标签。感谢您的建议
标签: javascript html css resize aspect-ratio