I have a webpage using the beta version of Bootstrap 4. This page has a built-in list. I want the contents of each list item to be vertically centered so that the items line up. As shown in this Bootply , they are currently out of center. I am using the following code:
<ul class="list-inline text-center align-items-center"> <li class="list-inline-item"><h2>Hello</h2></li> <li class="list-inline-item"><button class="btn btn-info btn-sm">Help</button></li> </ul>
My question is: how to get list items so that they are vertically centered?
It looks like flexbox has not been applied
Try the following:
.align-items-center { -ms-flex-align: center!important; align-items: center!important; display: flex; justify-content: center; }
Bootply Demo
: CSS , . li... ... , , , .
li
flexbox utils ( CSS ).
<ul class="list-inline text-center d-flex justify-content-center align-items-center"> <li class="list-inline-item"><h2>Hello</h2></li> <li class="list-inline-item"><button class="btn btn-info btn-sm">Help</button></li> </ul>
https://www.bootply.com/NLcGDLFEjJ
It is very simple. Just add the bootstrap class align-middleto the tags <li>.
align-middle
<li>
<ul class="list-inline text-center align-items-center"> <li class="list-inline-item align-middle"><h2>Hello</h2></li> <li class="list-inline-item align-middle"><button class="btn btn-info btn-sm">Help</button></li> </ul>
Hope this helps. You can check the result here .
Source: https://habr.com/ru/post/1684461/More articles:how to make git push origin --force; in Visual Studio Team Explorer - gitКак вставить вложенные данные json в таблицу mysql? - jsonVSTS: how to handle FileSystem WebPublishMethod at the Visual Studio build stage with multiple projects - visual-studioWhy can't I get access to renaming the superclass in Kotlin? - javaУдалите свойство из объекта без создания нового (без удаления) - javascriptSpecialize a member function of a C ++ class relative to a template class - c ++Delphi return function class object - delphiHow does mocha show the whole object in diff on a statement error? - javascriptDelphi error returning TList - delphi"md-card" не является известным элементом в материале 2 - angularAll Articles