0

Товарищи, помогите пожалуйста. Как сделать так, чтобы footer был в конце страницы вне зависимости от величины контента?

body {
    margin: 0;
    padding: 0;
    background-color: white;
    background-repeat: no-repeat;
    align-items: center;
    min-height: 100vh;
    width:100%;
    height:100%;
    display: flex;
    overflow-x: hidden;
    background-image: url("images/carouselback.jpg");
    background-size: 100% 70%;
    background-position-y: 65%;
    flex-direction: column;
    height: -webkit-fill-available;
}
::-webkit-scrollbar {
    width: 12px;
    height: 120px;
}
::-webkit-scrollbar-thumb {
    background: linear-gradient(transparent, #30ff00);
    border-radius: 6px;
}
::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(transparent, #00c6ff);
}
body {
    flex: 1 0 auto;
}
/* Шапка и логин */
.headmain {
    margin: 0;
    padding: 0;
    display: inline;
    text-align: center;
    font-size: 20px;
    border: 1px solid black;
    font-family: Arial;
    color: gold;
    font-weight: bold;
    font-style: oblique;
    width: 100%;
    height: auto;
    position: absolute;
    top: 100%;
    left: 0;
}
.headmain a {
    text-decoration: none;
    color: lawngreen;
}
.headmain a:hover {
    text-decoration: underline;
    color: lawngreen;
}

/Верхнее меню/ .topmenu li { display: inline; } .topmenu { margin: 0; padding: 0; width: 100%; height: 4%; border: 1px solid #c2c6c8; font-family: Consolas; text-align: left; background-color: none; position: absolute; top: 0; box-shadow: 0 0 1px grey; } .topmenu_kid { margin: 0; padding: 0; width: 100%; height: 4%; font-family: Consolas; text-align: left; background-color: none; position: absolute; top: 0; left: 10%; } .topmenu_kid_right { margin: 0 0 0 80%; padding: 0; width: 100%; height: 4%; text-align: left; background-color: none; position: absolute; top: 0; cursor: pointer; } .topmenu a { position: relative; color: black; margin: 0; padding: 10px 10px; font-size: 16px; overflow: hidden; text-decoration: none; font-weight: bold; display: inline-block; text-transform: uppercase; letter-spacing: 3px; transition: 0.2s; } .topmenu a:hover { color: red; } /Основное меню с товаром и скидками/ .linemenu li { display: inline; } .linemenu { margin: 0; padding: 0; width: 100%; height: 7%; border: 1px solid black; background: black; font-family: Consolas; text-align: center; justify-content: center; vertical-align: center; position: absolute; top: 15%; left: 0; } .linemenu a { position: relative; color: #2196f3; padding: 20px 35px; font-size: 24px; overflow: hidden; text-decoration: none; font-weight: bold; display: inline-block; text-transform: uppercase; letter-spacing: 3px; transition: 0.2s; } .linemenu a:hover { color: #255784; background: #2196f3; box-shadow: 0 0 10px #2196f3, 0 0 40px #2196f3, 0 0 80px #2196f3; transition-delay: 1s; } a span { position: absolute; display: block; } a span:nth-child(1) { top:0; left: -100%; width: 100%; height: 2px; background: linear-gradient(90deg, transparent, #2196f3); } a:hover span:nth-child(1){ left: 100%; transition: 0.7s; } a span:nth-child(3) { bottom:0; right: -100%; width: 100%; height: 2px; background: linear-gradient(270deg, transparent, #2196f3); } a:hover span:nth-child(3){ right: 100%; transition: 0.7s; transition-delay: 0.5s; } a span:nth-child(2) { top: -100%; right: 0; width: 2px; height: 100%; background: linear-gradient(180deg, transparent, #2196f3); } a:hover span:nth-child(2){ top: 100%; transition: 0.7s; transition-delay: 0.25s; } a span:nth-child(4) { bottom: -100%; left: 0; width: 2px; height: 100%; background: linear-gradient(360deg, transparent, #2196f3); } a:hover span:nth-child(4){ bottom: -00%; transition: 0.7s; transition-delay: 0.75s; }

/Регистрация/ #reg { margin: 10% 40%; padding: 0; background-color: #ECEDF0; border: 2px solid black; border-radius: 5px 5px; width: 20%; height: 40%; font-style: normal; font-size: 16px; color: black; display: none; text-align: center; position: fixed; left: 0; right: 0; top: 0; bottom: 0; z-index: 150; box-shadow: 0 0 10px #2196f3, 0 0 40px #2196f3, 0 0 80px #2196f3; } #reg input[type=text] { width: 150px; background-color: white; color: brown; padding: 2px 4px; margin: 4px 0; border: 1px solid black; border-radius: 4px; cursor: auto; box-shadow: 0 0 2px 2px white; } #reg input[type=password] { width: 150px; background-color: white; color: brown; padding: 2px 4px; margin: 4px 0; border: 1px solid black; border-radius: 4px; cursor: auto; box-shadow: 0 0 2px 2px white; } #reg input[type=submit] { width: 150px; background-color: green; font-size: 14px; color: white; padding: 4px 2px; margin: 2px 2px; border: none; border-radius: 2px; cursor: pointer; box-shadow: inset 0 0 6px black; } #regmistake { width: 100%; height: 5%; border: 1px solid orangered; font-size: 18px; color: red; } .close { width: 20px; height: 20px; padding: 2px; margin: 20px 20px 10px 87%; border: 1px solid black; cursor: pointer; } .close:hover { background: grey; }

/Вход на сайт/ #auth { margin: 10% 40%; padding: 0; background-color: #ECEDF0; border: 2px solid black; border-radius: 5px 5px; width: 20%; height: 20%; font-style: normal; font-size: 16px; color: black; display: none; text-align: center; position: fixed; left: 0; right: 0; top: 0; bottom: 0; z-index: 150; box-shadow: 0 0 10px #2196f3, 0 0 40px #2196f3, 0 0 80px #2196f3; } #auth input[type=text] { width: 150px; background-color: white; color: brown; padding: 2px 4px; margin: 4px 0; border: 1px solid black; border-radius: 4px; cursor: auto; box-shadow: 0 0 2px 2px white; } #auth input[type=password] { width: 150px; background-color: white; color: brown; padding: 2px 4px; margin: 4px 0; border: 1px solid black; border-radius: 4px; cursor: auto; box-shadow: 0 0 2px 2px white; } #auth input[type=submit] { width: 150px; background-color: green; font-size: 14px; color: white; padding: 4px 2px; margin: 2px 2px; border: none; border-radius: 2px; cursor: pointer; box-shadow: inset 0 0 6px black; } #authmistake { width: 100%; height: 5%; border: 1px solid orangered; font-size: 18px; color: red; } /Затемнение/ #gray { background-color: rgba(1,1,1,0.75); position: fixed; left: 0; right: 0; top: 0; bottom: 0; display: none; z-index: 100; } /Карусель/ .slideshow-container { margin: 0; padding: 0; position: absolute; width: 1300px; top: 30%; left: 18%; } .mySlides { overflow: hidden; height: 500px; } .mySlides img { width: 100%; height: 100%; } .prev, .next { cursor: pointer; position: absolute; top: 50%; width: auto; margin-top: -40px; color: #ECEDF0; font-weight: bold; font-size: 60px; transition: 0.6s ease; border-radius: 0 3px 3px 0; } .prev { left: 0; border-radius: 3px 0 0 3px; } .next { right: 0; border-radius: 3px 0 0 3px; } .prev:hover, .next:hover { color: #00c6ff; } /Футер/

footer { flex: 0 0 auto; position: absolute; height : 30%; bottom : 0; margin: 0 auto; padding: 0; width: 100%; font-size: 14px; color: #ECEDF0; background-color: #272727; overflow: hidden; } .footer1 { margin: 0; padding: 0;

}

<head>
    <?php
    require_once $_SERVER['DOCUMENT_ROOT'].'/head.php';
    ?>
</head>
<body>
<!-- Задний прозрачный фон -->
<div onclick="go('none')" id = "gray"></div>
<div onclick="show('none')" id = "gray"></div>
    <?php
    require_once $_SERVER['DOCUMENT_ROOT'].'/header.php';
    ?>
<div class="carouselback"></div>
<?php
require_once $_SERVER['DOCUMENT_ROOT'].'/carousel.php';
?>
    <?php
    require_once $_SERVER['DOCUMENT_ROOT'].'/main.php';
    ?>
<?php
require_once $_SERVER['DOCUMENT_ROOT'].'/getin.php';
?>
<?php
require_once $_SERVER['DOCUMENT_ROOT'].'/reg.php';
?>
<?php
require_once $_SERVER['DOCUMENT_ROOT'].'/carousel.js';
?>
</body>
<footer>
    <?php
    require_once $_SERVER['DOCUMENT_ROOT'].'/footer.php';
    ?>
</footer>
</html>

1 Answers1

1

Используйте такой вариант вёрстки.
При ней футер будет всегда снизу.

body {
  margin: 0;
}

.wrapper { display: flex; flex-direction: column; justify-content: space-between; min-height: 100vh; }

.content { background: #ddd; }

.footer { background: #444; }

<div class="wrapper">
  <div class="content">Content</div>
  <div class="footer">Footer</div>
</div>
De.Minov
  • 24,026