Brijesh Maurya
Brijesh Maurya

Reputation: 125

bootstrap collapse menu appearing above the menu

I making a website with bootstrap. I have made this code.

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Krishna Driver Services</title>

    <!-- Bootstrap -->
    <link href="css/bootstrap.min.css" rel="stylesheet">

    <link rel="stylesheet" type="text/css" href="webstyle.css">


  </head>
  <body>
    <div class="navbar navbar-default">      

      <div class="container">

        <div class="navbar-header">

           <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">

            <span class="sr-only">Toggle navigation</span>

            <span class="icon-bar"></span>

            <span class="icon-bar"></span>

            <span class="icon-bar"></span>

          </button>

          <a href="" class="navbar-brand">
            <img src="images\logo.png">
          </a>

        </div>
        <div class="collapse navbar-collapse navbar-right">

          <ul class="nav navbar-nav">
            <li><a href="">Home</a></li>
            <li><a href="">About Us</a></li>
            <li><a href="">Services</a></li>
            <li><a href="">Contact Us</a></li>
          </ul>

        </div>


      </div>
    </div>


    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

    <script src="js/bootstrap.min.js"></script>
  </body>
</html>

& this css code

.navbar-default{
    min-height:160px;   
}

My collapse menu is appearing just above the logo. I think it's occurring due to change of navbar width.

Upvotes: 0

Views: 622

Answers (1)

mmgross
mmgross

Reputation: 3092

UPDATE

It has been made clear to me in the comments that I missed the point of the question, so here's the real answer:

You have to make sure, that not only the navbar, but also the navbar-header change height. The obvious way to do that is to change your CSS to

.navbar-default, .navbar-default .navbar-header{
  min-height:160px;
}

Take a look at this fiddle: http://jsfiddle.net/cr2frn1p/6/

I'm sure there are other, more elegant solutions and I'm sure I've used one of them in a project not so long ago, but I currently have no time to search for it. If you're interested, I can include it here tomorrow.

ORIGINAL POST

Looks fine to me: http://jsfiddle.net/cr2frn1p/

Doing some guesswork here: You might be referring to the fact, that the top edge of the logo and the button are not perfectly aligned. That's because .navbar-brand has a padding of 15px while .navbar-toggle has a margin of 8px, just add this to your CSS:

.navbar-toggle {
  margin-top: 15px;
}

Upvotes: 1

Related Questions