Force sidebar height 100% using CSS (with a sticky bottom image)?

后端 未结 15 1268
再見小時候
再見小時候 2020-12-02 05:40

I\'ve been banging my head against the wall for hours trying to figure out this issue and think it must be something small I\'m missing. I\'ve searched online, but nothing

15条回答
  •  半阙折子戏
    2020-12-02 06:39

    I would use css tables to achieve a 100% sidebar height.

    The basic idea is to wrap the sidebar and main divs in a container.

    Give the container a display:table

    And give the 2 child divs (sidebar and main) a display: table-cell

    Like so..

    #container {
    display: table;
    }
    #main {
    display: table-cell;
    vertical-align: top;
    }
    #sidebar {
    display: table-cell;
    vertical-align: top;
    } 
    

    Take a look at this LIVE DEMO where I have modified your initial markup using the above technique (I have used background colors for the different divs so that you can see which ones are which)

提交回复
热议问题