更改Bootstrap导航栏的颜色并减小导航栏的高度

曼达·桑特(Mandarr Sant)

我正在引导程序中创建登录页面,因此我添加了固定的导航栏,其中右侧有登录表单,登录表单为导航栏增加了更多的高度,实际上我使用了位置移动到顶部,但导航栏的高度不是减少(我也尝试过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="[email protected]" 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放在您的页面中,它将根据您的需要进行工作。您可以根据需要更改值。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Bootstrap:如何更改导航栏的高度

来自分类Dev

Bootstrap活动菜单更改导航栏高度

来自分类Dev

更改导航栏文本颜色Bootstrap

来自分类Dev

Bootstrap导航栏-无法更改字体颜色

来自分类Dev

更改Bootstrap背景导航栏的颜色

来自分类Dev

无法更改Bootstrap CSS导航栏颜色

来自分类Dev

Bootstrap导航栏背景颜色未更改

来自分类Dev

Bootstrap 3导航栏高度

来自分类Dev

无法更改导航栏颜色

来自分类Dev

如何更改导航栏的颜色?

来自分类Dev

更改导航栏的默认颜色

来自分类Dev

更改导航栏标题的颜色

来自分类Dev

独立更改导航栏的颜色

来自分类Dev

更改折叠的导航栏颜色

来自分类Dev

Android更改导航栏颜色

来自分类Dev

在Bootstrap3中更改导航栏的高度

来自分类Dev

Twitter Bootstrap更改导航栏

来自分类Dev

Bootstrap 3导航栏活动李不更改背景颜色

来自分类Dev

如何使用jekyll bootstrap导航栏颜色进行更改?

来自分类Dev

BootStrap-列表悬停更改颜色-导航栏

来自分类Dev

如何在Bootstrap的此导航栏中更改文本的颜色?

来自分类Dev

Bootstrap 3 RC1-更改导航栏颜色

来自分类Dev

Bootstrap 3菜单导航栏随着向下滚动而更改颜色

来自分类Dev

如何在Bootstrap 3.3.6导航栏中更改悬停颜色?

来自分类Dev

如何更改 Bootstrap Creative-Tim 导航栏颜色?

来自分类Dev

是否可以更改 Bootstrap 4 中扩展导航栏的颜色?

来自分类Dev

Bootstrap 3-导航栏的高度

来自分类Dev

自定义高度Bootstrap的导航栏

来自分类Dev

Bootstrap折叠响应式导航栏高度