我正在尝试使用两个视频框构建类似 Skype 的界面:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
html, body
{
background-color: #000000;
height: 100%;
font-family: Verdana, Arial, Helvetica, sans-serif;
}
body
{
margin: 0;
padding: 0;
}
#videoContainer
{
position: relative;
max-width: 800px;
}
#bigRemote
{
/* Shrink if necessary */
max-width: 100%;
max-height: 100%;
}
#smallLocal
{
position: absolute;
height: 30%;
width: 30%;
bottom: 0;
right: 0;
}
</style>
</head>
<body>
<div id="videoContainer">
<video id="bigRemote" controls preload="none" poster="http://media.w3.org/2010/05/sintel/poster.png">
<source id="mp4" src="http://media.w3.org/2010/05/sintel/trailer.mp4" type="video/mp4" />
<source id="webm" src="http://media.w3.org/2010/05/sintel/trailer.webm" type="video/webm" />
<source id="ogv" src="http://media.w3.org/2010/05/sintel/trailer.ogv" type="video/ogg" />
<p>Your user agent does not support the HTML5 Video element.</p>
</video>
<video id="smallLocal" controls preload="none" poster="http://media.w3.org/2010/05/sintel/poster.png">
<source id="mp4" src="http://media.w3.org/2010/05/sintel/trailer.mp4" type="video/mp4" />
<source id="webm" src="http://media.w3.org/2010/05/sintel/trailer.webm" type="video/webm" />
<source id="ogv" src="http://media.w3.org/2010/05/sintel/trailer.ogv" type="video/ogg" />
<p>Your user agent does not support the HTML5 Video element.</p>
</video>
</div>
</body>
</html>
大框 ( bigRemote
) 代表远程视频流。小方框 ( smallLocal
),代表本地视频流。
我遇到了一个问题:当您垂直缩小结果窗口时,smallLocal
框会从bigRemote
. 原因是它smallLocal
绑定到的右下角,videoContainer
而后者并没有像原来那样收缩bigRemote
。
我的印象position: absolute
是在确定容器的布局/大小时会忽略孩子。当后者缩小时,我该如何videoContainer
适应?bigRemote
(我相信这样做会间接导致smallLocal
粘在.的右下角bigRemote
。)
- 我希望视频随其容器增大/缩小,因此您无法删除 max-width/height 或在
videoContainer
. - 我希望视频保持其纵横比,所以让它的大小匹配
videoContainer
也不行。