2014-01-31 89 views
0

我想在這裏做一些魔術。滾動內容中的特定固定格

我有一個主div,有限的寬度和高度。這有一個滾動xy。 裏面,我需要另一個對象,像一個酒吧,但這必須修復。和內容,必須向下滾動並離開。

想象一下,一個固定的表格,但我不能使用表格,我必須使用LI元素,否則。

CSS

.c {clear: both;} 
.thelimitedscrollediv {width:400px; height: 200px; overflow: scroll;} 
.fixedlargebar {position:fixed; background:#ccc; width:900px; height: 20px} 

HTML

<div class="thelimitedscrollediv"> 

<div class="fixedlargebar">The fixed bar. This needs to scroll X</div> 
<br class="c" /> 
And here the normal content. This have to scroll x y. 
</div><!-- @end of limitedscrollediv --> 

任何人都知道我可以解決這一問題?非常感謝!

+0

非常感謝Daniel,這很有效,但是,我需要修復這個問題。 –

回答

0

你的代碼中聲明:

<div class="fixedlargebar">The fixed bar. This needs to scroll X</div> 

W3C規範:

框的位置根據「絕對」的模式, 但除此之外,盒子固定相對於計算一些參考。由於 與'絕對'模型,該框的利潤率不崩潰與任何 其他利潤率。在手持式,投影,屏幕,tty和電視媒體類型的情況下,該框相對於視口是固定的,並且在滾動時不會移動 。 Full read

簡單的答案是你不能在沒有javascript的情況下實現你想要的。

+0

謝謝喬納森。我想這會解決這個問題https://github.com/bigspotteddog/ScrollToFixed –