How to stick footer to bottom (not fixed) even with scrolling

前端 未结 9 1036
温柔的废话
温柔的废话 2021-02-03 20:53

I\'m learning web development and I simply can\'t figure out what I\'m doing wrong on this. I want the footer of this page to stick to the bottom, below all content, but not fix

9条回答
  •  清酒与你
    2021-02-03 21:25

    I think this might help you.

    Just showing you the way how to achieve what you want.

    html,
    body {
      margin: 0;
      padding: 0;
      height: 100%;
    }
    #wrapper {
      min-height: 100%;
      position: relative;
    }
    #header {
      background: #ededed;
      padding: 10px;
    }
    #content {
      padding-bottom: 100px;
      /* Height of the footer element */
    }
    #footer {
      background: #ffab62;
      width: 100%;
      height: 100px;
      position: absolute;
      bottom: 0;
      left: 0;
    }

    Make sure the value for 'padding-bottom' on #content is equal to or greater than the height of #footer.

    Update:

    JSFiddle Demo to play around.

提交回复
热议问题