New We are sorting MAX channels into categories and territories. Read the news
Loading image…

Как сделать sticky footer без layout-багов?



Часто делают так:
footer {
position: fixed;
bottom: 0;
}


Но fixed-footer перекрывает контент и ломает mobile layout.

Есть нативный flex-способ без JS и вычислений высоты.
body {
display: flex;
flex-direction: column;
}


Теперь body становится вертикальным flex-контейнером.

Остаётся отодвинуть footer вниз.
footer {
margin-top: auto;
}


auto забирает всё свободное пространство сверху и footer автоматически прижимается к низу страницы.
body {
min-height: 100dvh;
}


Так layout занимает минимум всю высоту viewport даже при маленьком количестве контента.

Code Ready | #совет
Views: 229
Open in MAX Report an inaccuracy

Report an inaccuracy

Describe what needs fixing. If you have a source, add a link.

You are leaving datool.ru

The link leads to an external website. datool.ru is not responsible for its content — check the address before entering passwords or payment details.

Redirecting in 10 s

Go