bijoume
bijoume

Reputation: 365

Bootstrap navbar - align button vertically

I'm trying to align a button inside a nav but I can't figure out how to do it. I placed a logo with the height of 50px and aligned other nav items vertically with the line-height property of 50 px. Right now it looks like this:

enter image description here

When I add a line height to the button as well, the border gets streched out.

Here is my HTML:

<nav class="navbar navbar-default navbar-fixed-top">
        <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="#">
                    <img alt="Dolm IT" src="img/logo.svg" height="50px">
                </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 navbar-right">
                    <li><a href="#">services</a></li>
                    <li><a href="#">showcase</a></li>
                    <li><a href="#">our team</a></li>
                    <button type="button" class="btn btn-default navbar-btn">get in touch</button>
                </ul>
            </div>
            <!-- /.navbar-collapse -->
        </div>
        <!-- /.container-fluid -->
    </nav>

And here's my CSS:

  /*nav*/

    .navbar {
        background-color: transparent;
        border: 0;
    }

    .navbar-default .navbar-nav > li > a {
        color: #01787e;
        font-family: 'Akrobat-ExtraBold';
        font-size: 1rem;
        text-transform: uppercase;
        letter-spacing: 2px;
        margin-right: 50px;
    }

    .navbar-nav li a {
        line-height: 50px;
    }


    /*buttons*/

    .btn-default {
        color: #01787e;
        font-family: 'Akrobat-ExtraBold';
        font-size: 1rem;
        text-transform: uppercase;
        letter-spacing: 2px;
    }

    .btn {
        border: 2px solid #01787e;
        border-radius: 5px;
        padding: 7px 30px;
    }
    }

You can see the issue here. Thank you for your help.

Upvotes: 2

Views: 7689

Answers (3)

Aakash Thakur
Aakash Thakur

Reputation: 3895

Give your button.navbar-btn class a margin-top of 25px and you are good to go.

button.navbar-btn{
      margin-top:25px
    } 

Check fiddle: https://jsfiddle.net/4ku2jhm4/1/

Upvotes: 1

Michael
Michael

Reputation: 532

The top property may be the solution you need here.

.top {
  top: 50px;
}
.lineheight {
  line-height: 50px;
}
ul {
    list-style-type: none;
    margin: 0;
    overflow: hidden;
    border: 1px solid;
}

li {
    float: left;
    padding: 0px 5px;
}
<button class="top">top</button>
<button class="lineheight">lineheight</button>
<br><br>
<ul class="lineheight">
  <li><a href="#">services</a></li>
  <li><a href="#">showcase</a></li>
  <li><a href="#">our team</a></li>
  <button type="button" class="top">get in touch</button>
</ul>

Upvotes: 0

Try with this. I did not test it, but it would be something like this.

.nuevo{
    width:auto;
    text-align:center;
    line-height:40px;
    padding:5px;
    background:green;
    display:block;
}

     <ul class="nav navbar-nav navbar-right">
                        <li><a href="#">services</a></li>
                        <li><a href="#">showcase</a></li>
                        <li><a href="#">our team</a></li>
                        <li><a class="nuevo">get in touch</a></li>
                    </ul>

Upvotes: 0

Related Questions