i just started using bootstrap 4 and i’m unable to center text in a list-group .
In boostrap 3 , the following works perfectly :
.list-con {
text-align:center;
}
However in boostrap 4 . text-align only works for multi line text .
li {
text-align: center;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="list-con">
<ul class="list-group test">
<li class="list-group-item test-item">
Title
</li>
<li class="list-group-item test-item">
Title2
</li>
<li class="list-group-item test-item">
Morbi id neque a eros mattis tristique at a dolor. Quisque sapien tortor, suscipit ut varius id, dictum eget tortor. Sed elit diam, tincidunt sed fringilla a, dignissim in augue. Curabitur elementum ante eget erat eleifend, a blandit odio accumsan. Nullam
mattis urna nec elit dapibus, vel suscipit nulla dictum. Etiam erat magna, dictum eget pharetra et
</li>
</ul>
</div>
2
Answers
You can achieve centered text in list groups with
justify-content: center;
, whichSee MDN for more information.
You may use dedicated class to this https://v4-alpha.getbootstrap.com/utilities/flexbox/
https://v4-alpha.getbootstrap.com/utilities/flexbox/#justify-content