Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to center text vertically in Bootstrap's navbar-brand class?

I have a logo with some text. I want the text to be vertically aligned to the middle.

<a class="navbar-brand" href="foo"><img src="bar"/>FooBar</a>

navbar-brand is defined in Bootstrap like that:

.navbar-brand {
  float: left;
  height: 50px;
  padding: 15px 15px;
  font-size: 18px;
  line-height: 20px;
}

I've tried wrapping image together with text in span and set its style as follows:

vertical-align: middle; 
display: inline-block;

See JSFiddle

Could someone give me a hint, how should I center the text vertically?

like image 441
Arkadiusz Kałkus Avatar asked Dec 24 '22 09:12

Arkadiusz Kałkus


1 Answers

Use following css:

#foo {
    align-items: center;
    display: flex;
}

Use display:flex instead of display:inline-block.

Working Fiddle

like image 50
ketan Avatar answered Dec 28 '22 21:12

ketan