簡體   English   中英

更改Bootstrap導航欄的顏色並減小導航欄的高度

[英]Change the color of Bootstrap navbar and reduce the height of navbar

我正在引導程序中創建登錄頁面,因此我在其中添加了固定的導航欄,其中右側有登錄表單,登錄表單為導航欄增加了更多的高度,實際上我使用了位置移動到頂部,但導航欄的高度不是減少(我也嘗試過margin-top和padding-top),並且我想更改導航欄的顏色(我嘗試通過使用background-color和!important屬性更改導航欄的顏色)如何解決此問題

這是我的代碼

<html>
<head>
  <title>MyLandingPage</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<link href="https://fonts.googleapis.com/css?family=Pacifico" rel="stylesheet">
<link rel="stylesheet" href="http://s.mlcdn.co/animate.css">
<style>
*{
  margin: 0;
  padding: 0;
  position: relative;
}
.navbar-brand.navbar-header{
  font-size:30px;
  color:black;
}
.navbar{
  background-color: #5b4282;
}
#bodycontainer{
  background-image:url(wood.jpg);
  width:100%;
  background-size:cover;
}
form{
  position:relative;
  top:-50px;
}
#myheader h1{
  font-size: 60px;
  color:white;
  font-weight:bold;
  text-align:center;
  margin-top:250px;
  font-family: 'Pacifico', cursive;

}
#txt1{
  text-align:center;
  color:black;
  font-weight:bold;
}
#txt2{
  text-align:center;
  color:black;
  font-weight:bold;
}
#txt3{
  text-align:center;
  color:black;
  font-weight:bold;
}
#txt4{
  text-align:center;
  color:black;
  font-weight:bold;
}
.mybutton{
  margin-left:250px;
}
</style>
</head>
<body>
  <div class="container">
    <div class="navbar navbar-default navbar-fixed-top">
      <div class="navbar-brand navbar-header">
        My@PP
      </div>
      <div class="collapse navbar-collapse" id="navbar-example">

        <ul class="nav nav-pills">
            <li class="active"><a href="">Link 1</a></li>
            <li><a href="#">Link 2</a></li>
            <li><a href="#">Link 3</a></li>
            <li><a href="#">Link 4</a></li>
            <li><a href="#">Link 5</a></li>
        </ul>
        <form class="navbar-form navbar-right" id="myform">
          <input type="email" placeholder="username@abc.com" class="form-control"/>
          <input type="password" placeholder="*********" class="form-control"/>
          <button type="button" class="btn btn-info">Log-In</button>
          </form>

      </div>
      <button class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>

    </div>

  </div>
  <div class="container" id="bodycontainer">
    <div class="row">
      <div class="col-md-6 col-md-offset-3" id="myheader">
        <h1 class="animated ZoomIn infinite ">MY APPLICATION</h1>
        <p class="lead" id="txt1">This Why You Should Download The App</p>
        <p id="txt2">For more Information about the app please scroll down the more to access the information you can get the idea about it</p>
        <p id="txt3">If u are intrested please join our maling list</p>
        <br/>  <br/>  <br/>
        <form class="">
          <div class="input-group">
            <span class="input-group-addon" id="basic-addon1">@</span>
            <input type="text" class="form-control" placeholder="Username" aria-describedby="basic-addon1">
          </div>
        </form>

        <button type="button" class="btn btn-info btn-lg mybutton">Submit</button>

      </div>
    </div>

  </div>
  <div class="container">
    <div class="row">
      <h1 id="txt4">Why this app is Osome...?</h1>
    </div>
  </div>
  <script>
$("#bodycontainer").css("height",$(window).height());
  </script>


</body>
</html>

解決方案是用css值覆蓋來自引導程序的默認css值。

這里的navbar類控制着導航欄的最小高度和彩色背景色,因此更改其CSS屬性可以解決您的問題。

我已經完成了這一步:

.navbar {背景:紅色; max-height:50像素; }

將上面的CSS放在您的頁面中,它將根據您的需要工作。您可以根據需要更改值。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM