![](/img/trans.png)
[英]How to automatically resize iframe content size when browser window resize?
[英]Html resize iframe automatically to device size
<div style="position:absolute; top:50px; left:0px">
<iframe style="border: none;" src="./RedMan2.html" width="1350" height="900"></iframe>
</div>
如何自動調整 iframe 的大小以適應設備屏幕? 我剛開始學習 HTML、JS 和 CSS,所以如果我沒有留下足夠的代碼,請告訴我。 我才 11 歲。謝謝。
在大多數現代瀏覽器中,您可以使用分別等於屏幕寬度和高度的 1% 的vw
和vh
單位:
<div style="position:absolute; top:50px; left:0px">
<iframe style="border: none; width: 100vw; height: 100vh;" src="./RedMan2.html" width="1350" height="900"></iframe>
</div>
如果你的目標是舊瀏覽器,你可以設置width: 100%; height: 100%;
width: 100%; height: 100%;
對於iframe
及其父div
:
<div style="position:absolute; top:50px; left:0px; width: 100%; height: 100%;">
<iframe style="border: none; width: 100%; height: 100%;" src="./RedMan2.html" width="1350" height="900"></iframe>
</div>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.