Ziqi Liu
Ziqi Liu

Reputation: 3171

bootstrap navbars button vertical align

<nav class="navbar navbar-inverse navbar-static-top">
            <div class="container">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle collapsed"
                            data-toggle="collapse" data-target="#navbar"
                            aria-expanded="false" aria-controls="navbar">
                        <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="#">Grumblr</a>
                </div>
                <div id="navbar" class="navbar-collapse collapse">
                    <ul class="nav navbar-nav">
                        <li class="active"><a href="#">Home</a></li>
                        <li><a href="#about">About</a></li>
                        <li><a href="#contact">Contact</a></li>
                        <li class="dropdown">
                            <a href="#" class="dropdown-toggle"
                               data-toggle="dropdown" role="button"
                               aria-haspopup="true" aria-expanded="false">Dropdown
                                <span class="caret"></span></a>
                            <ul class="dropdown-menu">
                                <li><a href="#">Action</a></li>
                                <li><a href="#">Another action</a></li>
                                <li><a href="#">Something else here</a></li>
                                <li role="separator" class="divider"></li>
                                <li class="dropdown-header">Nav header</li>
                                <li><a href="#">Separated link</a></li>
                                <li><a href="#">One more separated link</a></li>
                            </ul>
                        </li>
                    </ul>
                    <ul class="nav nav-pills pull-right">
                        <li role="presentation" class="active"><a
                                href="#">test1</a></li>
                        <li role="presentation"><a href="#">test2</a></li>
                        <li role="presentation"><a href="#">test3</a></li>
                    </ul>
                </div>
            </div>
        </nav>

the three buttons test1,test2,test3 are supposed to be on the right of navbars and vertical align middle. But it look likes: img here

It there any css class can make it automatically aligned? Actually I'm new to css, just want to quickly build up my UI using bootstrap.....

Upvotes: 1

Views: 65

Answers (2)

Anil Shrestha
Anil Shrestha

Reputation: 1200

use height and padding to your anchor tag

.nav-pills a{
  padding-top: 17px !important;
  padding-bottom: 17px !important;
  height: 54px !important;
}

or you can give class to anchor tag and use this css. you can inspect to the other anchor tag you can see the same css

Upvotes: 0

Jade Cowan
Jade Cowan

Reputation: 2583

@Ziqi, here's a link to a codeply project that implements your navigation bar. It just has a CSS class to add a margin between the buttons and the top of the navigation bar.

Upvotes: 2

Related Questions