Flex Layout with fixed position (no scrolling) sidebar

前端 未结 3 845
不知归路
不知归路 2021-02-07 10:51

I have a layout with left and right canvas sidebars, enclosing the Main content area in the middle.

The sidebars and main content are flex items, positioned in a flex la

3条回答
  •  鱼传尺愫
    2021-02-07 11:54

    i dont know how do it with flex, but here is a easyer/alternate css remove all that flex... and try to never add padding to a outer div, its easyer in inner items, then you dont need to calculate if there are to many divs

    .flexcontainer {
        display: block;
        min-height: 100%;
        align-items: stretch;
    }
    .flexitem {
        display: flex;
    }
    #canvas-left {
        background: yellow;
        order: -1;
        left: 0px;
        width: 20%;
        position: fixed;
    }
    #content {
        position: absolute;
        background: green;
        order: 1;
        width: 60%;
        left: 20%;
    }
    #content p {
        display: block;
        padding: 1rem;
    }
    #canvas-right{
        background: blue;
        order: 2;
        right: 0px;
        width: 20%;
        position: fixed;
    }
    

提交回复
热议问题