我正在嘗試創建一個固定位置的側邊欄,它具有一個小標題和一個可滾動的div。溢出:滾動不顯示整個div
我的問題是,我無法滾動整個div,所以我不能看到它的一切。我的代碼是here it is on jsfiddle。
HTML
<section>
<header>we have some text here
<br>a few lines
<br>doesn't matter
<br>
</header>
<div class="scroll-box">FIRST LINE
<br>a few lines
<br>doesn't matter
<br>we have some text here
<br>a few lines
<br>doesn't matter
<br>we have some text here
<br>a few lines
<br>doesn't matter
<br>we have some text here
<br>a few lines
<br>doesn't matter
<br>we have some text here
<br>a few lines
<br>doesn't matter
<br>we have some text here
<br>a few lines
<br>doesn't matter
<br>we have some text here
<br>a few lines
<br>doesn't matter
<br>we have some text here
<br>a few lines
<br>doesn't matter
<br>we have some text here
<br>a few lines
<br>doesn't matter
<br>we have some text here
<br>a few lines
<br>doesn't matter
<br>we have some text here
<br>a few lines
<br>doesn't matter
<br>we have some text here
<br>a few lines
<br>LAST LINE
<br>
</div>
CSS
section {
position: fixed;
top:0;
left: 0;
height: 100%;
width: 300px;
background: red;
}
.scroll-box {
overflow: scroll;
height: 100%;
width: 100%;
background: #eee;
}
感謝
這似乎是問題所在。但是,我怎樣才能使其響應?我知道標題的高度是多少,因爲它不會改變,但我希望滾動框垂直填充屏幕的其餘部分。 我知道如何使用jQuery,但我不知道是否有CSS解決方案。 – Alex
我不認爲它只能用於CSS,特別是用於「溢出」......他需要一個固定的高度。 – DaniP
我會用jQuery來做。謝謝 ! – Alex