【问题标题】:Change the color of Bootstrap navbar and reduce the height of navbar更改 Bootstrap 导航栏的颜色并降低导航栏的高度
【发布时间】:2016-07-09 16:25:35
【问题描述】:

我在引导程序中创建了一个登陆页面,所以我添加了固定导航栏,其中我在右侧有登录表单,登录表单为导航栏增加了更多高度,实际上我使用位置移动到顶部,但高度导航栏没有减少(我也尝试了margin-top和padding-top)而且我想改变导航栏的颜色(我试图通过使用背景颜色和!重要属性来改变导航栏的颜色)我该如何解决这个问题问题

这是我的代码

<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>

【问题讨论】:

  • 你能给我们提一下你的代码吗?

标签: html css twitter-bootstrap-3


【解决方案1】:

解决方案是用您的 css 值覆盖来自引导程序的默认 css 值。

这里的导航栏类是控制导航栏的最小高度和颜色背景颜色,所以改变它们的css属性可以解决你的问题。

我已经完成了这个:

.navbar{ 背景:红色;最大高度:50px; }

将上面的css放在你的页面中,它会按照你的意愿工作。你可以根据需要更改值。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-03
    • 2017-08-23
    • 1970-01-01
    • 1970-01-01
    • 2014-08-16
    • 1970-01-01
    相关资源
    最近更新 更多