【发布时间】:2014-10-07 19:07:51
【问题描述】:
我通常使用与this one 类似的解决方案。比如:
.wrapper {
position: relative;
width: 100%;
height: 0;
padding-bottom: 56.25%;
}
.wrapper iframe {
position:absolute;
left: 0;
top: 0;
height: 100%;
width: 100%;
}
但这次我无法访问 HTML 或 JavaScript 代码,因此我无法使用包装器来阻止 height:0。
有没有办法只使用 CSS 使 iframe 响应式(并保持比例)?
试过这个(适用于 iframe,但不适用于其内容):
iframe {
width: 100%;
background: red;
height: 0;
padding-bottom: 33%;
}
有什么想法吗?无需支持旧浏览器,因此即使是 CSS3 解决方案也很棒。
【问题讨论】:
标签: html css iframe responsive-design