我有一段文字,我希望能夠滾動而不顯示垂直滾動條。我跟着這個,但沒有用,文本滾動,但滾動條仍然可見。 Hide scroll bar, but while still being able to scroll無法隱藏垂直滾動條
#activity_parent {
height: 100%;
width: 100%;
overflow: hidden;
}
#activity_child {
width: 100%;
height: 100%;
overflow-y: scroll;
padding-right: 17px; /* Increase/decrease this value for cross-browser compatibility */
}
<html>
<body>
<div id="activity_parent">
<div id="activity_child">
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
good<br/>bye.
</div>
</div>
</body>
</html>
那是因爲你正在使用'高度; 100%'在父元素上,這意味着它將擴展以適應內容的全部高度。您將需要聲明一個值,該值不受**內容高度的影響:它是'25%',一個視口單位,一個固定像素/ em/rem/pt值。如果你說,設置父高度爲200px,你會看到它的工作。 – Terry
嗨特里,使用50%仍然顯示滾動條。爲什麼這個工作與高度:100%? http://jsfiddle.net/5GCsJ/954/ – Dercni