Can't scroll to top of flex item that is overflowing container

后端 未结 7 2417
再見小時候
再見小時候 2020-11-21 05:08

So, in attempting to make a useful modal using flexbox, I found what seems to be a browser issue and am wondering if there is a known fix or workaround -- or ideas on how to

7条回答
  •  伪装坚强ぢ
    2020-11-21 05:23

    2 Container Flex Method with Table fallback tested IE8-9, flex works in IE10,11. Edit: Edited to ensure vertical centering when minimal content, added legacy support.

    The issue stems from height being inherited from the viewport size which causes children to overflow, as Michael answered. https://stackoverflow.com/a/33455342/3500688

    something more simple and use flex to maintain the layout within the popup container(content):

    #popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    min-height: 100vh;
    background-color: rgba(0,0,0,.25);
    margin: auto;
    overflow: auto;
    height: 100%;
    bottom: 0;
    display: flex;
    align-items: flex-start;
    box-sizing:border-box;
    padding:2em 20px;
    }
    .container {
    background-color: #fff;
    margin: auto;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
    /* width: 100%; */
    max-width: 500px;
    padding: 10px;
        /* display: flex; */
        /* flex-wrap: wrap; */
    }
    		

提交回复
热议问题