I'm utilising the following Bootstrap modal on a site (simplified example with fewer list items):
#manufacturer-modal .modal-body {
padding: 0;
}
#manufacturer-modal .nav-item {
list-style: none;
}
#manufacturer-modal .nav-link {
font-size: 1.2em;
font-weight: 500;
letter-spacing: -1px;
display: flex;
align-items: center;
justify-content: left;
width: 100%;
height: 3.5em;
border-bottom: 1px solid #dee2e6;
padding: 0;
}
#manufacturer-modal .nav-link img {
width: 80%;
max-width: 2.6em;
margin: 0 1.5em;
display: block;
}
.show {
display: block !important;
}
<div class="modal-body">
<li class="nav-item">
<a class="nav-link" href="#">
<img src="/images/badges/img.svg" alt="">
<span>Item 1</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">
<img src="/images/badges/img.svg" alt="">
<span>Item 2</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">
<img src="/images/badges/img.svg" alt="">
<span>Item 3</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">
<img src="/images/badges/img.svg" alt="">
<span>Item 4</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">
<img src="/images/badges/img.svg" alt="">
<span>Item 5</span></a>
</li>
</div>
By default it is left-aligned which, although tidy, would look better centered:
However, when I center it with justify-content:center
, it loses its tidy alignment along the left-edge:
How can I get the best of both worlds by keeping the items aligned to the same left edge while also centering them in the middle of the modal? It occurs to me that what I want probably involves some form of margins and/or padding, but no amount of messing around with them in dev tools gets this working, so I'm obviously missing something and I'm now at a loss.