I have a web page that uses the Bootstrap 4 beta. In this page, I have an inline list. I want the content of each list item to be vertically centered so the items line up. As shown in this Bootply, they're currently off-center. I'm 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 do I get the list items to be vertically centered?
Use the included flexbox utils (no extra CSS is needed)..
https://www.bootply.com/NLcGDLFEjJ
It looks as though flexbox hasn't been applied
Try this:
Bootply Demo
Note: there is no CSS method of vertically aligning the contents of elements that do not share a parent with each other. The above aligns the
li
...not their contents..but seems to have the effect you are looking for.Its very simple. Just add the bootstrap class
align-middle
to both the<li>
tags.Hope this helps. You can check the result here.