Why doesn't my sticky footer stick?

后端 未结 7 641
甜味超标
甜味超标 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:01

    In order to realize a sticky footer, that is a footer placed in a fixed position at the bottom of the webpage that doesn't move when your scroll the page you can use this css code:

    #footer{
    position:fixed;
    clear:both;
    }
    

    position:fixed makes the footer sticky anyway there could be floating problems if you used float:left or float:right in your code before, so using also clear:both it clears the floating and ensures that the footer is at the bottom under other divs and not on the left or right of the precedent div.

提交回复
热议问题