аватар |

Статьи / CSS /

Как закрепить футер или подвал внизу web-страницы CSS?

Вы скорее всего уже не раз видели, что футер страницы был закреплён внизу, независимо от объёма контента. Сделаем это средствами CSS!



Как закрепить футер (footer) или подвал внизу web-страницы?



1. Начнём со стилей - файл style.css

html, body {
  margin: 0;
  display: table;
  height: 100%;
  width: 100%;
  font-family: Calibri, sans-serif;
}

.wrapper {
  padding: 20px;
  height: auto;
}

footer {
  background: #f1f1f1;
  display: table-row;
  height: 1px;
}


2. Код HTML
Тут вся разметка и lorem ipsum (шаблонный текст).

<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Отзывчивый футер</title>
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <div class="wrapper">
   Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
  </div>
  <footer>
   <div class="wrapper">
    It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
   </div>
  </footer>
</body>
</html>


3. Оба файла должны быть в одной директории.
Теперь меняем размеры окна браузера и смотрим за тем, как футер закреплён внизу.

4. Смотрим пример работы закреплённого внизу футера.

Демонстрация Скачать исходники


Спасибо за внимание и удачи!
 



Похожие статьи


Комментарии к статье (vk.com)