I am currently using Bootstrap 4 and trying to center a pagination
UL horizontally inside a grid column. Since the pagination
is now displayed using flex
, I am facing difficulties in getting it properly centered.
I aim to achieve this without adding any extra CSS and only utilizing existing Bootstrap classes.
I have attempted using text-center
, mx-auto
, align-items-center
but unfortunately, none of them seem to do the trick.
<div class="container">
<div class="row">
<div class="col-lg-6 offset-lg-3 py-5 border">
<ul class="pagination mx-auto">
<li class="page-item disabled">
<a class="page-link" href="#" aria-label="Previous">
<span aria-hidden="true">«</span>
<span class="sr-only">Previous</span>
</a>
</li>
<li class="page-item active">
<a class="page-link" href="#">1</a>
</li>
<li class="page-item"><a class="page-link" href="#">2</a></li>
<li class="page-item"><a class="page-link" href="#">3</a></li>
<li class="page-item"><a class="page-link" href="#">4</a></li>
<li class="page-item">
<a class="page-link" href="#" aria-label="Next">
<span aria-hidden="true">»</span>
<span class="sr-only">Next</span>
</a>
</li>
</ul>
</div>
</div>
</div>
You can view the code example here