Paper9oll Paper9oll - 1 year ago 149
CSS Question

Bootstrap 4 : Vertically Align Navigation Links when Logo Increases the Navbar Height

I'm new to the Bootstrap 4 framework, but even after reading all the documentation and all the existing B4 questions on StackOverFlow, I'm still a bit stuck.

In my navigation bar, I inserted a SVG logo that has a height and width of 50px. This automatically makes the navbar taller. I have not adjusted any CSS for this, it is simply the logo that is forcing the navbar height to increased.

Here is my HTML:

<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0">
<link rel="import" href="elements.html">
<link rel="stylesheet" href="/styles/app.css">
<header class="navbar navbar-light navbar-fixed-top bd-faded">
<div class="clearfix hidden-sm-up">
<button class="navbar-toggler pull-right" data-toggle="collapse" data-target="#navbar">
<a href="/" class="navbar-brand">
<img src="/images/brand.svg" alt="Logo">
<div class="collapse navbar-toggleable-xs" id="navbar">
<a href="/" class="navbar-brand">
<img src="/images/brand.svg" alt="Logo">
<nav class="nav navbar-nav">
<div class="nav-item nav-link"><a href="#">Link 1</a></div>
<div class="nav-item nav-link"><a href="#">Link 2</a></div>
<div class="nav-item nav-link"><a href="#">Link 3</a></div>
<script src=""></script>
<script src="/scripts/vendor.js"></script>
<script src="/scripts/bootstrap.js"></script>
<script src="/scripts/app.js"></script>
<script src="/components/webcomponentsjs/webcomponents.js"></script>

Here is my Custom CSS:

.navbar-brand {
font-size: 22px;
img {
display: inline-block;
margin-right: 8px;
width: 50px;
height: 50px;

I'd like the navigation links which is link1, link2, & link3 to be vertically align to the title which is Bootstrap.

Thanks You in Advance

Answer Source

I think you can remove top and bottom padding from links and add height and line-height to it. Also remove padding from .navbar-brand.

Just add this CSS:

.navbar-brand {
  padding: 0;
.navbar-nav .nav-link {
  padding-top: 0;
  padding-bottom: 0;
  height: 50px;
  line-height: 50px;


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download