[英]How to have an iframe fill up the entire mobile web page after setting a negative top margin
我目前有一個iframe填充了我的整個頁面,但我想給它一個-40px的上邊距,以使其看起來更好。
iframe位於移動頁面上,寬度為640px,高度為100%。
我嘗試這樣做: height="calc(100% + 40px)"
但這似乎沒有用,相反,它使我在頁面頂部的小條形寬度得以顯示。
但這本質上就是我想要的,我想在將頁面擴大到40px之后將其內嵌到頁面底部。
請有人在這里保存我的一天哈哈!
碼:
<html>
<meta content='width=350px, user-scalable=0' name='viewport' />
<body style="margin: 0; height: 100%;">
<iframe style='margin-top: -40px;'
src="URLHERE"
frameborder="0"
width="350px"
height="100%">
</frameset>
</body>
</html>
</iframe>
您需要執行@ APAD1所說的操作,再加上40px到100%的高度。 但是,這也會將滾動條也向上移動40px,並可能最初將其隱藏。 這是一個完整的全角/全角iframe解決方案,頂部為-40px:
html, body
{
height: 100%;
overflow: hidden;
}
.iframe
{
position:absolute;
top:-40px;
left:0;
width:100%;
height:calc(100% + 40px);
}
在這里提琴: http : //jsfiddle.net/60xs8bro/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.