How to make child div scrollable when it exceeds parent height?

后端 未结 3 874
情书的邮戳
情书的邮戳 2021-02-02 11:48

I have 2 child divs nested in a parent div in row-column pattern: the parent is a column, and the children are rows.\"enter

3条回答
  •  死守一世寂寞
    2021-02-02 11:50

    Because this post is still ranking very high in Google, I'd like to post a better solution using flexbox. Actually this is very simple. Use display: flex, flex-direction: column and overflow: hidden for parent and overflow-y: auto for child.

    .wrapper {
      display: flex;
      flex-direction: column;
      overflow: hidden;
    }
    
    .scrollable-child {
      overflow-y: auto;
    }
    

    Here's the pen: https://codepen.io/pawelsas/pen/vdwjpj

提交回复
热议问题