HTML5 flexible box model height calculation

后端 未结 3 1186
走了就别回头了
走了就别回头了 2020-11-30 02:21

after researching the flexible box model for a whole day, I must say I really like it. It implements the functionality I implement in JavaScript in a fast and clean way. One

3条回答
  •  南方客
    南方客 (楼主)
    2020-11-30 03:12

    I've been wrestling with this myself, but have finally managed to come up with a solution.

    See this jsFiddle, although I have only added webkit prefixes so open in Chrome.

    You basically have 2 issues which I will deal with separately.

    1. Getting the child of a flex-item to fill height 100%
      • Set position:relative; on the parent of the child.
      • Set position:absolute; on the child.
      • You can then set width/height as required (100% in my sample).
    2. Fixing the resize scrolling "quirk" in Chrome
      • Put overflow-y:auto; on the scrollable div.
      • The scrollable div must have an explicit height specified. My sample already has height 100% but if none is already applied you can specify height:0;

    See this answer for more information on the scrolling issue.

提交回复
热议问题