Auto height div with overflow and scroll when needed

后端 未结 10 2385
醉梦人生
醉梦人生 2020-12-08 06:45

I\'m trying to make a website with no vertical scrolling for a page, but i need that one of the DIVs i have to expand vertically to the bottom of the page (at most), and tha

10条回答
  •  醉酒成梦
    2020-12-08 06:51

    This is what I managed to do so far. I guess this is kind of what you're trying to pull out. The only thing is that I can still not manage to assign the proper height to the container DIV.

    JSFIDDLE

    The HTML:

    FIXED DIV (TOP)
    CONTENT
    CONTENT
    CONTENT
    CONTENT
    CONTENT
    CONTENT
    CONTENT
    CONTENT
    CONTENT
    CONTENT
    CONTENT
    CONTENT
    CONTENT
    CONTENT
    CONTENT
    CONTENT
    CONTENT
    CONTENT
    CONTENT
    CONTENT
    CONTENT
    CONTENT
    CONTENT
    CONTENT
    CONTENT
    CONTENT
    CONTENT
    CONTENT
    CONTENT
    CONTENT
    CONTENT
    CONTENT
    FIXED DIV (BOTTOM)

    And the CSS:

    html {
        height:100%;
    }
    body {
        height:100%;
        margin:0;
        padding:0;
    }
    #container {
        width:600px;
        height:50%;
        text-align:center;
        display:block;
        position:relative;
    }
    #header {
        background:#069;
        text-align:center;
        width:100%;
        height:80px;
    }
    #fixeddiv-top {
        background:#AAA;
        text-align:center;
        width:100%;
        height:20px;
    }
    #content-container {
        height:100%;
    }
    #content {
        text-align:center;
        height:100%;
        background:#F00;
        margin:0 auto;
        overflow:auto;
    }
    #fixeddiv-bottom {
        background:#AAA;
        text-align:center;
        width:100%;
        height:20px;
    }
    

提交回复
热议问题