[英]Height of div adjusting to resolution
您可以使用: div {height:100vh;}
參見https://www.w3.org/TR/css3-values/#viewport-relative-lengths
大眾汽車
等於初始包含塊的寬度的1%。
在下面的示例中,如果視口的寬度為200mm,則h1元素的字體大小將為16mm(即(8×200mm)/ 100)。
`h1 { font-size: 8vw }`
甚高頻單位
Equal to 1% of the height of the initial containing block.
vmin單位
Equal to the smaller of vw or vh.
vmax單位
Equal to the larger of vw or vh.
另請參閱http://caniuse.com/#feat=viewport-units以獲取瀏覽器支持
CSS具有視口和視高度單位(即vw
和vh
)
在您的CSS中添加:
div {
height: 100vh;
}
您可以使用
div { width: 100%; height: 100%; min-width: 1000px; min-height: 1000px; }
這樣的div不能小於1000像素,但對移動瀏覽器來說不是很好。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.