【发布时间】:2014-04-25 04:01:46
【问题描述】:
我正在设计一个介绍页面。我在该页面上放置了背景和视频片段,并且我还想在移动设备中查看桌面视图。我尝试了以下代码:
css:
.trailer-content {
max-width: 75%;
width: 600px;
margin-left: auto;
margin-right: auto;
}
.video-container {
position: relative;
padding-bottom: 56.25%;
padding-top: 30px;
height: 0;
}
.video-container iframe,
.video-container object,
.video-container embed {
position: fixed;
bottom:40px !important;
width: 50%;
height: 50%;
margin-left: auto !important;
margin-right: auto !important;
}
#background {
width: 100%;
height: 100%;
position: fixed;
left: 0px;
top: 0px;
z-index: -1; /* Ensure div tag stays behind content; -999 might work, too. */
}
.stretch {
width:100%;
height:100%;
}
html:
<div id="background">
<img src="img/bg.jpg" class="stretch" alt="" />
</div>
<div class="trailer-content">
<div class="video-container"><iframe width="420" height="315" src="//www.youtube.com/" frameborder="0" allowfullscreen></iframe>
</div>
</div>
输出结果
背景被拉伸
视频在桌面端正常,但在移动端视图中,视频也被拉伸到一定大小。
【问题讨论】:
标签: html css video responsive-design background-image