How to make a fixed column in CSS using CSS Grid Layout?

前端 未结 8 1824
南方客
南方客 2020-12-04 18:35

I\'ve made a simple site with a #container div that is parent to two divs: #left and #right, by using Grid Layout:

Is there an

8条回答
  •  离开以前
    2020-12-04 19:08

    Add one more div in right panel which panel you want to scroll for that give some max-height and overflow: auto; so left panel will be stick and right panel content will scroll.

    body {
        margin: 0 0 0 0;
    }
    
    #container {
        display: grid;
        grid-template-columns: 50% 50%;
    }
    
    .section {
        padding: 5% 5% 5% 5%;
    }
    
    #left {
        background-color: aquamarine;
    }
    
    #right {
        background-color: beige;
    }
    .scroll-div {
        max-height: 300px;
        overflow: auto;
    }

    This should not scroll

提交回复
热议问题