Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Navigation won't vertically align

Tags:

html

css

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/

like image 316
Kami Avatar asked Nov 08 '15 05:11

Kami


People also ask

How to align vertically center in bootstrap?

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.

How do you center NAV vertically?

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.


2 Answers

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

like image 182
Alex Avatar answered Oct 24 '22 04:10

Alex


#cssmenu{
width:100%;
padding-top:13px;
}

Try it out.

like image 3
Ajay Makwana Avatar answered Oct 24 '22 02:10

Ajay Makwana