Position footer at the bottom

前端 未结 6 1012
抹茶落季
抹茶落季 2021-01-14 16:50

I would like to position the footer at the bottom of the page.

For example on the page where there\'s not much content, I still need the footer at the bottom, but if

6条回答
  •  青春惊慌失措
    2021-01-14 17:41

    This can be done using only CSS.

    Here is the main part of a HTML file which contains nav, main and footer.

    ...
    
    
    ...
    ...
    ...

    In your CSS add the following lines

    ...
    .main {
        ...
        min-height: calc(100vh - )
    }
    ...
    

    Now, if there is no content within main the min-height will make sure to make the main take the whole viewport and if there are any contents in the main, the min-height does not matter.

提交回复
热议问题