CSS Layout Help - Stretch div to bottom of page

后端 未结 3 1840
天命终不由人
天命终不由人 2020-12-16 13:57

I\'m trying to create a layout with a \'header\' area which contains a logo and some links, and then a content area which needs to extend to the bottom of the page. This is

3条回答
  •  忘掉有多难
    2020-12-16 14:26

    http://jsfiddle.net/CZayc/

    this works by wrapping the header and body in a div to push footer down

    index.html

    main
    main
    main
    main
    main
    main

    style.css

    body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td { 
        margin:0;
        padding:0;
    }
    #header {
        border-top:20px solid #fff;
        height: 33px;
        line-height: 33px;
        text-align: center;
        background-color: green;
    }
    html { height: 100%; }
    body { height: 100%; width: 90%; margin: auto; }
    #wrap { min-height: 100%;background-color:gray;}
    #main {
        overflow: auto;
        padding-bottom: 53px; /* must be same height as the footer */
        background-color: red;
        height: 90%
    }
    #footer {
        position: relative;
        margin-top: -53px; /* negative value of footer height */
        height: 33px;
        line-height: 33px;
        border-bottom:20px solid #fff;
        text-align: center;
        background-color:blue;
    }
    

提交回复
热议问题