Bootstrap导航栏固定大小

时间:2016-06-01 08:34:21

标签: html css twitter-bootstrap-3

您好我不希望我的导航栏在折叠或最小化时调整大小。我想要修复尺寸。有人可以给我一些想法吗?请给我线索。我应该使用媒体查询吗?还是只是一个基本的CSS?

这是图片,当它没有崩溃时,这是我想要的尺寸。 enter image description here

这是导航崩溃时的情况。它变小了。具体来说就是它的高度。你无法在图片中清楚地看到。 enter image description here

这是我的HTML

<!DOCTYPE html>
<html>
<head>
    <title>Student Portal</title>
    <link rel="stylesheet" href ="css/bootstrap.min.css">
    <link rel="stylesheet" href="font-awesome/css/font-awesome.min.css">
    <link href="style.css" rel ="stylesheet">
    <link rel="shortcut icon" type="img/png" href="img/asd.png"/>
</head>
<body>
    <div class ="top-bar-dark">
        <div class="container">
            <div class="row">
                  <div class="col-sm-4 col-xs-7">
                        <div class="top-bar-socials">
                            <a href="https://www.facebook.com/pages/Governor-Andres-Pascual-CollegeNavotas-City/344134628983014?fref=ts">
                                <i class="fa fa-facebook"></i>
                            </a>
                            <a href="https://twitter.com/official_gapc">
                                <i class="fa fa-twitter"></i>
                            </a>
                            <a href="https://www.linkedin.com/company/governor-andres-pascual-college-in-navotas-city">
                                <i class="fa fa-linkedin"></i>
                            </a>
                        </div>
                    </div>
                    <div class="col-sm-8 col-xs-5 text-right">
                        <ul class="list-inline top-dark-right">                      
                            <li class="hidden-sm hidden-xs"><i class="fa fa-envelope"></i> gapc_school@yahoo.com.ph</li>
                            <li class="hidden-sm hidden-xs"><i class="fa fa-phone"></i> (02) 282-9036</li>
                            <li><a href="#" class="login"><i class="fa fa-lock"></i> Login</a></li>
                        </ul>
                    </div>
            </div>
        </div>
    </div>
        <nav class="navbar navbar-default navbar-static-top">
    <div class="container">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#nav-collapse">
                <span class="icon-bar" ></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>  
            </button>
               <img class="img-responsive"src="images/brandz.png"> 

        </div>

    <div class="collapse navbar-collapse" id="nav-collapse"> 
        <ul class="nav navbar-nav navbar-right">
            <li class="active"><a href="#">Home</a></li>
            <li class="dropdown">
            <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">About us</a>
            <ul class="dropdown-menu">
              <li><a href="#">History</a></li>
              <li><a href="#">Mission and Vision</a></li>
            </ul>
            <li><a href="#">Admissions</a></li>
            <li><a href="#">Contact us</a></li>
             <li><a href="#">Faculty Portal</a></li>
        </ul>
    </div>
</div>
</nav>
    <script src="js/jquery-1.12.4.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
</body>
</html>

这是我的css

.top-bar-dark {
  background-color: #a92419;
}

.top-bar-light {
  background-color: #f3f3f3;
}
.top-bar-light .top-dark-right li {
  border-color: #ddd;
}

.top-bar-light .top-dark-right li a:hover {
  color: #32c5d2;
}
.top-bar-socials {
  line-height: 30px;
  padding-top: 5px;
}
.top-bar-socials:after {
  display: table;
  clear: both;
  content: "";
}
.top-bar-socials a {
  margin: 0px 8px;
  text-decoration: none;
  font-size:18px;
  color: #fff;
}

.top-dark-right {
  margin: 0px;
  padding: 0px;
}

.top-dark-right li {
  line-height: 40px;
  border-left: 1px solid #932015;
  padding: 0px 10px;

}

.top-dark-right li, .top-dark-right li a {
  color: #d7d7d7;
  font-size: 12px;
}

.top-dark-right li i {
  margin-right: 5px;
}

.top-dark-right li a:hover {
  color: #fff;
}
a.login{
  text-decoration: none;
}
.fa-facebook:hover{
  color:#3b5998;
}
.fa-twitter:hover{
  color:#1dcaff;
}
.fa-linkedin:hover{
  color:#007bb5;
}
.navbar-default .navbar-nav > li > a {
 font-weight: 590;
 color: #949494;
 display: block;
 padding: 5px 35px 2px 45px;
 border-bottom: 3px solid transparent;
 line-height: 70px;
 text-decoration: none;
 transition: border-bottom-color 0.5s ease-in-out;
 -webkit-transition: border-bottom-color 0.5s ease-in-out; 
 }
 .nav.navbar-nav > li > a:hover, .nav.navbar-nav > li.active a{
    color:#a92419;
    border-bottom-color: #a92419;
  }
  .navbar-default .navbar-nav>.active>a, .navbar-default .navbar-nav>.active>a:focus, .navbar-default .navbar-nav>.active>a:hover {
    color: #a92419;
    background-color: white;
}
 .navbar-default{
 background-color:#fff;
 margin: 0;

 }
 .nav>li>a {
 position: relative;
 }
.navbar-default .navbar-right > li > a {
padding: 0 30px;
margin-right:6px;
 }
.navbar-default .navbar-toggle .icon-bar {
 background-color: #000000;
 margin:0 0 4px;
 width: 25px;
 height: 5px;
}
 .nav.navbar-nav > li{
 display: :inline-block;
 }
 .nav.navbar-nav{
 list-style-type:none;
 }
 .nav.navbar-nav > li > a:hover{
    color:#a92419;
   border-bottom-color: #a92419;
  }

  .navbar-default .navbar-toggle .icon-bar {
  background-color:#a92419 ;
  margin:0 0 4px;
  width: 25px;
  height: 5px;

  }
  .navbar-default .navbar-toggle:focus, .navbar-default .navbar-toggle:hover{
  background: none;
  }
  button.navbar-toggle{
  background:none;
  border:none;
  color:#000;
  margin: 0px;
}
.dropdown:hover .dropdown-menu {
  display: block;
}

.dropdown-menu>li>a:hover {
    color:#a92419;
}
.dropdown-menu>li>a {
    display: block;
    padding: 3px 20px;
    clear: both;
    font-weight: 400;
    line-height: 3em;
    color: #333;
    white-space: nowrap;
}
.dropdown:hover a.dropdown-toggle {
  border-bottom-color: #a92419;
  color:#a92419;
}

UPDATE *** 大小已经相等,但现在这是问题所在。 enter image description here

2 个答案:

答案 0 :(得分:1)

您可以通过添加以下样式来定义导航栏的显式高度:

// To set the height on the navbar
.navbar-header{
  height: 74px;
}

// To subsequently vertically align the collapsed menu
.navbar-toggle{
  position: relative;
  top: 15px;
}

工作示例:http://codepen.io/JasonGraham/pen/Gqgvod

答案 1 :(得分:1)

min-heightmax-height添加到导航栏并将其设为相同的值。