Scrolling div without fixed height

前端 未结 3 931
故里飘歌
故里飘歌 2021-02-01 03:44

I need to build a dynamically-resizing scrolling div.

The div should dynamically resize to fit the screen. But if the content doesn\'t fit on the screen, it should disp

3条回答
  •  我在风中等你
    2021-02-01 04:41

    You could stretch the div using absolute positioning. This way it will always take the size of the browser window (or the closest positioned ancestor).

    Given this HTML:

    the CSS should be something like:

    #gridcontainer {
      position: absolute;
      top: 0; bottom: 0; left: 0; right: 0;
      overflow: auto;
    }
    

    Live Demo

提交回复
热议问题