1
我不確定這個問題是否曾經發布過,但我不知道如何有效地提出這個問題。以百分比形式使用高度時div的位置不正確
在我的網站中,我一個接一個地創建了兩個大的部分(不是指標籤),一個人的身高設置爲100%,另一個設置爲90%。我在第二部分的正下方添加了一個div。爲了保持div卡住,我已經將「top」設置爲190%,以便模擬這兩部分的長度。儘管我已經爲每個部分設置了最小高度,這使得div在停止調整大小時在部分下方爬行。
我怎樣才能避免這一點,而使用「位置:絕對」的元素? (使用一個較大的部分)
HTML例如:
<html>
<body>
<div class="section1"></div>
<div class="box"></div>
</body>
</html>
CSS例子:
.section1 {
display: inline-block; width: 100%; height: 100%; min-height: 500px;
position: absolute;
}
.box {
width: 100%; height: 200px;
position: absolute; top: 100%; margin-top: 50px;
}
感謝,
喬納森
這工作,謝謝! :D –
@JonathanFogelströmnp,很高興能幫到你:D –