overflow (scroll) - 100% container height

前端 未结 2 970
独厮守ぢ
独厮守ぢ 2021-02-07 04:24

i\'m trying to have a floated div (call it \'sidebar\') display 100% of container height, and scroll if necessary.

if the sidebar has more content (height) than the cont

2条回答
  •  后悔当初
    2021-02-07 05:07

    In most modern browsers, you can also do

    .your-scrollable-div {
      height: calc(100%);
      overflow-y: scroll;
    }
    

    I've seen this work with Chrome & Firefox, but Safari balks here.

提交回复
热议问题