'Custom django pagination in CSS
I would like that the buttons of pagination have a little space between them ! Not like what I have right now :
I do not get how the parameter display and justify work together. What should I change in the css to space them. Thank you for your help. Here is my code :
html
<div class="pagination">
{% if files.has_previous %}
<a class="pagination-action" href="?page=1">
<i class='bx bx-chevrons-left' aria-hidden="true"></i> </a>
<a class="pagination-action" href="?page={{ files.previous_page_number }}">
<i class='bx bx-chevron-left' aria-hidden="true"></i>
</a>
{% endif %}
{% for num in files.paginator.page_range %}
{% if files.number == num %}
<span class="pagination-number pagination-current">{{ num }}</span>
{% elif num > files.number|add:'-3' and num < files.number|add:'3' %}
<a class="pagination-number" href="?page={{ num }}">{{ num }}</a>
{% endif %}
{% endfor %}
{% if files.has_next %}
<a class="pagination-action" href="?page={{ files.next_page_number }}">
<i class='bx bx-chevron-right' aria-hidden="true"></i>
</a>
<a class="pagination-action" href="?page={{ files.paginator.num_pages }}">
<i class='bx bx-chevrons-right' aria-hidden="true"></i>
</a>
{% endif %}
</div>
css
.pagination {
display: flex;
margin-top: 15px;
align-items: center;
justify-content: center;
}
.pagination a {
text-decoration: none;
}
.pagination-number {
padding: 12px 17px;
border-radius: 2px;
color: #fff;
background-color: #6D85C7;
}
.pagination-number:hover,
.pagination-current {
background-color: #3354AA;
}
.pagination-action {
margin: 0 2px;
display: flex;
padding: 1px 2px;
color: #fff;
font-size: 1.3em;
align-items: center;
}
.pagination-action:hover,
.pagination-previous,
.pagination-next {
color: #3354AA;
}
Solution 1:[1]
I modified this part of my code :
#customers .iconsColumn{
display: flex;
flex-direction: row;
justify-content : space-around;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Maikiii |

