[英]make the whole page scroll beneath a certain height at the top without any scroll bar
HTML:
<div class="div_fixed"></div>
<div class="other_content">
content goes here
</div>
CSS:
.div_fixed{
position:fixed;
height:40px;
}
.other_content{
height:200px;
}
div_fixed
將保持固定在頁面的頂部位置。
但是當頁面向上滾動時,div other_content
的內容將在div div_fixed
的下邊緣消失。
在向下滾動的情況下, other_content
的不可見內容將從div_fixed
的下邊緣開始可見
怎么實現呢?
編輯:任何div都不應該出現滾動條
使用overflow: hidden
來擺脫滾動條
我已經使用了你的HTML / CSS並添加了一些jsFiddle - 我認為為了達到你想要的效果,你只需要讓你的內容足夠高,可以滾動。 在200px高和一行文本時,沒有任何內容可以滾動。
所以我讓你的other_content
div更高,然后在你的.div_fixed
選擇器中添加一個top: 0
,使其保持在屏幕頂部,並且一個margin-top: 40px
到.other_content
div以便讓它啟動在浮動div下面。
如果你想要它是一個導航欄類型的東西,你當然可以添加width: 100%
到.div_fixed
。
如果你想要的話,所有這些都應該很容易地轉移到容器div(有position: relative
),盡管你可能需要重新定位固定的div。
這是你在找什么? http://jsfiddle.net/BCRPa/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.