Responsive iframe for different aspect ratio

梦想的初衷 提交于 2019-12-08 11:59:28

问题


I followed this post Making an iframe responsive to make iframes responsive.

# A test case
<div class="intrinsic-container">
    <iframe frameborder="0" width="640" height="498" src="https://v.qq.com/iframe/player.html?vid=y0379t92gl9&tiny=0&auto=0" allowfullscreen></iframe>
</div>

# style.css
.intrinsic-container {
    position: relative;
    /* padding-bottom: 56.25%; /* 16:9 */
    padding-bottom:75%; /* 4:3 */
    /* padding-bottom: 66.66%; /* 3:2 */
    /* padding-top: 25px; */
    height: 0;
}

.intrinsic-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

It works. My question is how to make iframes responsive for different aspect ratios of content areas, such as

  • YouTube video: width="560" height="315", the ratio is 16:9
  • width="640" height="498", the ratio is 4:3

来源:https://stackoverflow.com/questions/42496354/responsive-iframe-for-different-aspect-ratio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!