html – 沒有固定高度的滾動條/帶滾動條的動態高度
我有這個HTML結構:
<div id="body"> <div id="head"> <p>Dynamic height without scrollbar</p> </div> <div id="content"> <p>Dynamic height with scrollbar</p> </div> <div id="foot"> <p>Fixed height without scrollbar</p> </div> </div>
我想在主要部分(#body)中沒有溢位的三個部分.所以我在中間需要一個滾動條.
我試過這個CSS:
#content{ border: red solid 1px; overflow-y: auto; }
和這個:
#content{ border: red solid 1px; overflow-y: auto; height: 100%; }
但他們都不工作.
我在ofollow,noindex" target="_blank">JSFiddle 做了一個例子.
我可以只用CSS和HTML嗎?我寧願避免使用Javascript.
你必須指定一個固定的高度,你不能使用100%,因為沒有什麼可以比較,如在height = 100%的什麼?
編輯小提琴:
程式碼日誌版權宣告:
翻譯自:http://stackoverflow.com/questions/10980822/scrollbar-without-fixed-height-dynamic-height-with-scrollbar