I have been trying to vertically align on my navigation menu. I tried display:table-cell; vertical-align: middle;
, but it just won't.
I do not want to apply padding-top or margin top
.
How do I manage to do this?
My fiddle https://jsfiddle.net/Tokyo/27kquzm3/
One way to vertically center is to use my-auto . This will center the element within it's flexbox container (The Bootstrap 4 . row is display:flex ). For example, h-100 makes the row full height, and my-auto will vertically center the col-sm-12 column.
The key is to place the logo image in the first <li> element of your list. You then display all the elements of the list as inline and use vertical-align: middle to line them up. You can adjust the padding and margin properties to get the exact look that you need.
You have to give display:table
to the ul
and remove float:left;
and then give display:table-cell;vertical-align:middle;
to the li
element.
#cssmenu > ul > li {
display: table-cell;
vertical-align: middle;
}
#cssmenu ul
{
display: table;
height: 100%;
}
Jsfiddle
#cssmenu{
width:100%;
padding-top:13px;
}
Try it out.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With