How to code a sticky footer using the html object, in HTML and CSS?

前端 未结 8 1432
刺人心
刺人心 2020-12-21 15:01

I\'m using Less Framework 4 for two websites I\'m designing. In both designs I want to apply a 5 pixel border both on top and bottom of the document.

The problem: be

8条回答
  •  囚心锁ツ
    2020-12-21 15:26

    Here is how I added a body border at the bottom:

    body {
      box-sizing: border-box;
      min-height: 100vh;
      margin: 0;
      border-bottom: solid 5px #ad3127;
      padding-top: 1px;
    }

    content

    The key is min-height: 100vh, which ensures that body height will at least be height of the viewport. Because of box-sizing: border-box, border of the body will be accounted in the body height. There is still a problem of content margins pushing the border below viewport, but that can be fixed with an arbitrary padding-top value.

提交回复
热议问题