2011-06-24 18 views
3

Javascriptを入手する前にCSSでこれを行う方法があるかどうかを確認するだけです!CSS、動的コンテンツを含む固定位置部門 - その下に別の部門を配置する方法

この例では、#fixed divにはコンテンツが動的に埋められているため、そのdivのコンテンツの大きさは決してわかりません。

#absolute divの先頭は常に#fixed divの下に表示する必要があります。 #absolute divには長時間のコンテンツが動的に埋め込まれるため、ユーザーはそのdivのコンテンツをどれだけ大きくしてもスクロールできる必要があります。

#fixed divのサイズを知らなくても、#fixed divの下の#absolute divの先頭を維持できるCSSのみを使用する方法はありますか?

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; 
} 

答えて

1

#FIXED のdivのサイズを知らなくても、私たちは下#absolute div要素の始まりを保つことができる唯一のCSS を使用して方法があります#fixed div?

いいえCSSはここでお手伝いできません。通常の流れ全体 ([および持っ]以降の兄弟に何ら影響)から除去

absolute/fixed要素は...

と:絶対 配置要素の

内容は、私がいないと思っ

http://www.w3.org/TR/CSS21/visuren.html#absolute-positioning

+0

周り 他のボックスは流れません!あなたの返信ありがとう:) – FrediDoo

+0

問題はありません。 JavaScriptに関する助けが必要ですか? – thirtydot

+0

私はすべていいよ、もう一度ありがとう! – FrediDoo

関連する問題