只需檢查是否有方法在CSS中執行此操作,然後再啓動Javascript即可!CSS,具有動態內容的固定位置Div - 如何在其下方放置另一個Div?
在該示例中,#fixed div被動態填充內容 - 所以我們永遠不知道該div內容會有多大。
#absolute div的開頭必須始終在#fixed div下面呈現。 #absolute div也會動態地填充冗長的內容,所以用戶必須能夠滾動該div中的內容,無論它有多大。
不知道#fixed div的大小,有沒有一種方法只使用CSS,我們可以將#absolute div的開頭保留在#fixed div下面?
XHTML:
<div id="right">
<p>This div is just here to force a scrollbar.</p>
</div>
<div id="fixed">
<p>This div gets filled dynamically with content of varying length</p>
</div>
<div id="absolute">
<p>This div also gets filled dynamically with content of varying length,
and needs to stay underneath the div above.</p>
<p>This div will sometimes get so high that it stretches below the bottom of the page,
and because it's inside a fixed positioned div the user won't be able to read all of its content.</p>
</div>
CSS:
#fixed {
position:fixed;
border:2px solid green;
width:200px;
display:block;
background-color:white;
}
#absolute {
position:absolute;
border:2px solid red;
width:200px;
margin-top:90px;
z-index:-1;
}
#right {
position:absolute;
right:0px;
width:200px;
height:4000px;
border:2px solid blue;
}
我認爲不是!感謝您的回覆:) – FrediDoo
沒問題。你需要JavaScript的幫助嗎? – thirtydot
我很好,再次感謝! – FrediDoo