您应该使用Media Queries. 给那个元素aclass &;根据不同的屏幕大小,通过媒体查询设置样式。
以下是示例:
HTML
<div align="center">
<div class="resolution">
<div style="position: relative; padding-bottom: 50.00%; padding-top: 35px; height: 0; overflow: hidden;">
<iframe style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;" src="html-websiteaddress" width="640" height="360" allowfullscreen="allowfullscreen"></iframe></div>
</div>
</div>
CSS
For bigger screens (laptop/desktop) use different widths like:
@media screen and (max-width: 1280px) { <-- /* Whatever screen size you want to put here */
.resolution {
width: 75%;
height: 75%;
}
}
For smaller screens (mobile/tab) use different widths like:
@media only screen and (max-width: 640px) { <-- /* Whatever screen size you want to put here */
.resolution {
width: 100%;
height: 75%;
}
}
为了更好地理解媒体查询,这里提供了一些参考资料:
Web Design Media Query &;
Media Rule