Set vertical scroll on a container with unknown height

后端 未结 1 1210
-上瘾入骨i
-上瘾入骨i 2021-01-26 16:56

Is it possible to set a vertical scroll on a container with unknown height using flexbox?

I can not use max-height as it will limit the hei

1条回答
  •  生来不讨喜
    2021-01-26 17:01

    flex has some short comings/bugs/flaws, or what ever to call them, and need an inner absolute element to force the scroll.

    html, body{
      height: 100%;
      overflow: hidden;
    }
    .list{
      display: flex;
      flex-direction: column;
      height: 100%;
    }
    header {
      flex: 0;
    }
    .vertical {
      flex: 1;
      position: relative;  
    }
    .scroll {  
      position: absolute;
      left: 0;
      top: 0;
      right: 0;
      bottom: 0;
      overflow: auto;
    }
    Some header
    • Item1
    • Item2
    • Item3
    • Item4
    • Item5
    • Item6
    • Item7
    • Item8
    • Item9
    • Item10
    • Item11
    • Item12
    • Item13
    • Item14
    • Item15
    • Item16
    • Item17
    • Item18
    • Item19
    • Item20
    • Item21
    • Item22
    • Item23
    • Item24
    • Item25
    • Item26
    • Item27
    • Item28

    0 讨论(0)
提交回复
热议问题