Why doesn't my sticky footer stick?

后端 未结 7 693
甜味超标
甜味超标 2021-01-14 19:34

I\'ve browsed to all question related to \"sticky footer\" and nothing helped me because my #content div does not always have sufficient content to push the footer to the bo

7条回答
  •  轮回少年
    2021-01-14 20:10

    This will work, no matter what the height of the #container is:

    CSS:

        html, body {
            height: 100%;
        }
    
        #container {
            min-height: 100%;
            height: auto !important;
            height: 100%;
            margin-bottom: -50px;
            position: relative;
        }
    
        #index_footer {
            height: 50px;
            line-height: 50px;
            position: relative;
            background: #CCC;
        }
    
        #push {
            height: 50px;
        }
    

    HTML:

    test

提交回复
热议问题