希望這是你在找什麼:
http://jsfiddle.net/CjV6k/1/
的CSS:
#scrollFrameWrap {
width: 400px;
margin: 20px auto;
background: #000;
border-radius: 8px;
box-shadow: 0px 1px 15px 0 #fff inset;
padding: 3px 10px 10px;
}
.title {
text-align: center;
font-size: 12px;
color: #aaa;
}
#parentElement {
height: 150px;
padding-bottom: 10px;
margin-bottom:10px;
}
#scrollFrame {
width: 380px;
height: 100%;
overflow: scroll;
overflow-x: hidden;
background: #fff;
border-radius: 4px;
padding: 10px;
}
的HTML:
<div id="scrollFrameWrap">
<p class="title">Title</p>
<div id="parentElement">
<div id="scrollFrame">
<p>This is a sentence, hope you like it.</p>
<p>This is a sentence, hope you like it.</p>
<p>This is a sentence, hope you like it.</p>
<p>This is a sentence, hope you like it.</p>
<p>This is a sentence, hope you like it.</p>
<p>This is a sentence, hope you like it.</p>
<p>This is a sentence, hope you like it.</p>
<p>This is a sentence, hope you like it.</p>
<p>This is a sentence, hope you like it.</p>
<p>This is a sentence, hope you like it.</p>
</div>
</div>
</div>
看看是否有幫助
我不想將'height:100%'設置爲'.content',因爲我想讓'.content'的大小根據其中的內容進行調整。然後在你的例子中,'.content'總是佔據整個高度。 – hguser
我發現了一個應該可以工作的解決方案,請參閱:http://jsfiddle.net/RL6EM/ –
事實上,在發佈此問題之前,我已嘗試過您的解決方案,但是我想''.windowContent'滾動而不是'。內容' – hguser