rufus rufus - 1 month ago 12
CSS Question

How to make Bootstrap navbar brand image larger

I am having a slight issue trying to increase the size of my navbar brand image i have inside my main navigation. It seem like it wont go any larger the 50px. I would like it around 100px high but just cant seem to work out how to do it. I currently have it in the center of the navigation with the burger menu along side it.

Would anyone know how to achieve what i am trying to do?

HTML:

<nav class="navbar navbar-default custom-nav">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"></a>
</div>

<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">About <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">History</a></li>
<li><a href="team.php">Meet The Team</a></li>
<li><a href="#">Facilities</a></li>
<li><a href="#">Opening Times</a></li>
<li><a href="membership.php">Membership</a></li>
</ul>
</li>
<li><a href="#">Diary</a></li>
<li><a href="lessons.php">Lessons</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"> Events<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="corporate.php">Corporate Days </a></li>
<li><a href="hens_stags.php">Hens & Stags</a></li>
<li><a href="#">Group Bookings</a></li>
</ul>
</li>
<li><a href="#">Gallary</a>
</li>
<li><a href="contact.php">Contact</a>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>


CSS:

.navbar-brand {
background: url(../img/logo.png);
background-position: center;
background-repeat: no-repeat;
background-size: contain;
width: 300px;
transform: translateX(-50%);
left: 50%;
position: absolute;
padding: 0;
}

.navbar-default .navbar-toggle .icon-bar {
background-color: #fff;
}

.navbar .navbar-nav {
display: inline-block;
float: none;
vertical-align: top;
}

.navbar .navbar-collapse {
text-align: center;
}

.custom-nav {
color: #fff;
background: #718373;
border-radius: 0;
margin-bottom: 0;
border: 0;
}

.custom-nav .navbar-nav>li>a {
color: #fff;
margin: 0 auto;
}

.custom-nav .navbar-nav>li>a:hover,
.custom-nav .navbar-nav>li>a:focus {
color: #fff;
}

.navbar-default .navbar-toggle:focus,
.navbar-default .navbar-toggle:hover {
background: none;
}

.custom-nav .navbar-nav>.open>a,
.custom-nav .navbar-nav>.open>a:focus,
.custom-nav .navbar-nav>.open>a:hover {
color: #fff;
background: none;
}

.custom-nav .navbar-nav li {
margin: 0 auto;
text-align: center;
width: 150px;
}

.dropdown-menu {
padding: 0;
margin: 0;
background: #718373;
border: none;
box-shadow: none;
min-width: 90px;
}

.dropdown-menu li:last-child a {
margin-bottom: 10px;
}

.dropdown-menu>li>a {
display: block;
clear: both;
font-weight: normal;
color: #fff;
width: 95%;
margin: 0 auto;
text-align: center;
padding: 20px 0;
}

.dropdown-menu>li>a:focus,
.dropdown-menu>li>a:hover {
color: #fff;
text-decoration: none;
background: none;
outline: 2px solid white;
outline-offset: -2px;
}


This is how it looks at the moment

Logo image

EDIT after adding

.navbar-header .navbar-brand {
height: 100px;
}


new logo image

Answer

Your styles are overwritten by Bootstraps navbar styles. Use higher specificity to make your styles apply to the navbar-brand, e.g. with

.navbar-header .navbar-brand {
  height: 100px;
}

This way you can overwrite the height.

.navbar-header .navbar-brand {
  background: url(../img/logo.png);
  background: url(//placehold.it/300x100);
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  height: 100px;
  width: 300px;
  transform: translateX(-50%);
  left: 50%;
  position: absolute;
  padding: 0;
  : #fff;
}
.navbar .navbar-nav {
  display: inline-block;
  float: none;
  vertical-align: top;
}
.navbar .navbar-collapse {
  text-align: center;
}
.custom-nav {
  color: #fff;
  background: #718373;
  border-radius: 0;
  margin-bottom: 0;
  border: 0;
}
.custom-nav .navbar-nav>li>a {
  color: #fff;
  margin: 0 auto;
}
.custom-nav .navbar-nav>li>a:hover,
.custom-nav .navbar-nav>li>a:focus {
  color: #fff;
}
.navbar-default .navbar-toggle:focus,
.navbar-default .navbar-toggle:hover {
  background: none;
}
.custom-nav .navbar-nav>.open>a,
.custom-nav .navbar-nav>.open>a:focus,
.custom-nav .navbar-nav>.open>a:hover {
  color: #fff;
  background: none;
}
.custom-nav .navbar-nav li {
  margin: 0 auto;
  text-align: center;
  width: 150px;
}
.dropdown-menu {
  padding: 0;
  margin: 0;
  background: #718373;
  border: none;
  box-shadow: none;
  min-width: 90px;
}
.dropdown-menu li:last-child a {
  margin-bottom: 10px;
}
.dropdown-menu>li>a {
  display: block;
  clear: both;
  font-weight: normal;
  color: #fff;
  width: 95%;
  margin: 0 auto;
  text-align: center;
  padding: 20px 0;
}
.dropdown-menu>li>a:focus,
.dropdown-menu>li>a:hover {
  color: #fff;
  text-decoration: none;
  background: none;
  outline: 2px solid white;
  outline-offset: -2px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<nav class="navbar navbar-default custom-nav">
  <div class="container">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="#"></a>
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav">
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">About <span class="caret"></span></a>
          <ul class="dropdown-menu">
            <li><a href="#">History</a>
            </li>
            <li><a href="team.php">Meet The Team</a>
            </li>
            <li><a href="#">Facilities</a>
            </li>
            <li><a href="#">Opening Times</a>
            </li>
            <li><a href="membership.php">Membership</a>
            </li>
          </ul>
        </li>
        <li><a href="#">Diary</a>
        </li>
        <li><a href="lessons.php">Lessons</a>
        </li>
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"> Events<span class="caret"></span></a>
          <ul class="dropdown-menu">
            <li><a href="corporate.php">Corporate Days </a>
            </li>
            <li><a href="hens_stags.php">Hens & Stags</a>
            </li>
            <li><a href="#">Group Bookings</a>
            </li>
          </ul>
        </li>
        <li><a href="#">Gallary</a>
        </li>
        <li><a href="contact.php">Contact</a>
      </ul>
    </div>
    <!-- /.navbar-collapse -->
  </div>
  <!-- /.container-fluid -->
</nav>