Как добавить нижний колонтитул в конце сайта, который содержит цикл for в html?
Я использовал :
.footer{
position: relative;
height: 130px;
clear: both;
background-color: red;
для установки колонтитула в конце сайта, но теперь колонтитул не в конце всех продуктов:
html:
{% load static %}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="{% static 'main.css' %}">
</head>
<body style="background-color: #36454F;">
{% for i in p%}
<div class='card'>
<div class="number">{{i.Number}}</div>
<img src="{{i.image}}"></img>
<p id="id">{{i.description}}</p>
<a href="{{i.buy}}" target='_blank' rel='noopener noreferrer'>
<button><span class="price"> ${{i.price}}</span> buy</button>
</a>
</div>
{%endfor%}
<div class="footer">
<h3>hello</h3>
</div>
</body>
</html>
css:
.card {
max-width: 400px;
margin: 0auto;
text-align: center;
font-family: arial;
border-style: solid;
border-width: 6px;
position: relative;
top: 611px;
margin-bottom: 33px;
margin-right: 33px;
justify-content: center;
float: left;
}
.footer{
position: relative;
height: 130px;
clear: both;
background-color: red;
}
.card img{
height: 400px;
width: 400px;
vertical-align: middle;
}
.price {background-color: #f44336;
font-size:22px;
border-radius: 3px;
position: absolute;
bottom: 0px;
right: 0px;
padding: 3px;
}
.card button {
border: none;
color: white;
background-color: #000;
position: relative ;
cursor: pointer;
width: 100%;
height: 100px;
font-size: 44px;
align-items: center;
}
.card button:hover {
opacity: .5;
background-color: #330;
}
#id{
background-color: palevioletred;
color: white;
margin: 0;
font-size: 17px;
}
.number{
width: 50px;
height: 50px;
background-color: #330;
color: yellow;
border-radius: 50%;
position: absolute;
top: -22px;
right: -22px;
justify-content: center;
align-items: center;
display: flex;
font-size: 22px;
}
@media (max-width: 1864px){
.card{
max-width: 300px;
}
.price{
font-size:20px;
}
.card img{
height: 300px;
width: 300px;
}
Я хочу иметь нижний колонтитул в конце сайта, даже если я хочу добавить больше товаров с помощью json в django restframework. (Есть еще одна проблема, я не могу создать нижний колонтитул в цикле for, поэтому я решил создать нижний колонтитул из этого цикла, но то, что я сделал, не работает)
Я попытался установить дно, чтобы довести его до конца:
.footer{
position: relative;
bottom: -674px;
height: 130px;
clear: both;
background-color: red;
}
Потом я изменил размер браузера:
но я хочу такой колонтитул :
Как я могу решить эту проблему?
Чтобы установить нижний колонтитул в нижней части страницы, нужно использовать следующий CSS:
.footer {
position:absolute;
bottom:0;
width:100%;
height:60px; /* Height of the footer */
background:#6cf; /* Set your own background */
}
Если вы хотите, чтобы он оставался внизу страницы и растягивался по низу, я бы сделал что-то подобное с CSS
.footer {
position: fixed;
left: 0;
bottom: 0;
width: 100%;
background-color: (whatever you want);
color: (color of the text, whatever you want);
text-align: center; /*unless you want the text aligned differently*/
}
Также посмотрите, как использовать grid-контейнер, если вы хотите, чтобы элементы колонтитула располагались рядами, как в приведенном вами примере.
Вам нужно, чтобы тег footer выполнял свою работу!
Подробнее о теге футера читайте здесь: https://www.geeksforgeeks.org/html5-footer-tag/
Вместо этого сделайте следующее:
<div class="footer">
<footer>
<h3>hello</h3>
</footer>
</div>