How can I force my footer to stick to the bottom of any page in CSS?

前端 未结 10 1054
谎友^
谎友^ 2020-12-16 10:52

This is my code:

#footer {
   font-size: 10px;
   position:absolute;
   bottom:0;
   background:#ffffff;
}

I\'ve no idea what is wrong with

10条回答
  •  生来不讨喜
    2020-12-16 11:07

    The wrapper is the rest of your page. The negative/positive margin/height values are where the magic happens.

    .wrapper 
      {
        min-height: 100%;
        height: auto !important;
        height: 100%;
        margin: 0 auto -142px;
      }
    .footer, .push 
      {
        height: 142px; /* .push must be the same height as .footer */
      }
    

提交回复
热议问题