简体   繁体   中英

Bootstrap navbar height changed on inserting brand image

I am new to HTML and CSS and have started coding in the last 4 days. I found bootstrap very useful to get things moving quickly.

Here is my attempt at getting a Navbar with transparency and fixed to the top.

http://jsfiddle.net/revanur/mf5wc/4/

<!-- Top-Navigation-Bar -->
<div class="row-fluid">
    <div class="navbar navbar-fixed-top">
        <div class="navbar-inner" id="topbar">
            <div class="container"> <a href="#"><img class = "brand" src="http://placehold.it/269x50" alt="SparkCharger" /></a>

                <button id="topbtn" type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">    <span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span>
                </button>
                <div class="nav-collapse">
                    <ul class="nav pull-right">
                        <li class="active">
                            <form class="navbar-search brand">
                                <input type="text" class="search-query" placeholder="Search">
                            </form>
                        </li>
                        <li><a href="#"> <h5> Discover </h5></a>
                        </li>
                        <li><a href="#"> <h5> Blog </h5></a>
                        </li>
                        <li class="dropdown">   <a class="dropdown-toggle" data-toggle="dropdown" href="#"><h5>Start <span class="caret"></span></h5></a>

                            <ul class="dropdown-menu">
                                <li><a href="#"> <h6> Login </h6></a>
                                </li>
                                <li><a href="#"> <h6> Signup </h6></a>
                                </li>
                            </ul>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- /Top-Navigation-Bar -->

However, the height of the navbar seems to change based on brand image size. I have no problem with that but I notice significant spacing between the image and the navbar top and bottom. How do I change this. Also, is it possible to fix the navbar size so that the navbar does not have a mind of its own.

There are a few things affecting the height of the navbar:

  1. div class="navbar-inner" (5px padding)
  2. img class="brand" (10px padding)
  3. the size of the image

You can remove the padding by:

img.brand {
  padding: 0;
}

And/Or you can specify the height of the navbar:

div.navbar-inner {
    height: 10px;
}

Use something like this:

.brand {height: 25px;}

Demo: Fiddle

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM