Я использую этот фрагмент кода из здесь (показано ниже) для горизонтального выравнивания элементов в группе списков (в Bootstrap 4).
.list-group.list-group-horizontal{
display: flex;
flex-direction: row;
}
.list-group.list-group-horizontal .list-group-item {
margin-bottom: 0;
margin-right: 0;
border-right-width: 0;
}
.list-group.list-group-horizontal .list-group-item:first-child {
border-top-right-radius:0;
border-bottom-left-radius:4px;
}
.list-group.list-group-horizontal .list-group-item:last-child {
border-top-right-radius:4px;
border-bottom-left-radius:0;
border-right-width: 1px;
}
Как мне отцентрироватьвыровнять список группы?Я попытался добавить класс text-center
и некоторые другие вещи, однако мне это не удалось.
<div id="app" class="container my-container">
<!-- Header -->
<h2 class="text-center" >Sample Header</h2>
<!-- Buttons -->
<div class="list-group list-group-horizontal">
<a href="#" class="list-group-item active">Categories</a>
<a href="#" class="list-group-item">Search</a>
</div>
</div>
Codepen