javascript - Bootstrap 导航栏顶部的图像

标签 javascript jquery html css twitter-bootstrap

我试图在 Bootstrap 导航栏顶部添加一个图像,但是我无法在导航栏中添加一个带有额外“栏”的图像。

最佳答案

您可以将图像构建到导航栏中,因为您使用固定位置进行导航。这篇文章也可能有助于您尝试实现的其他功能:SO Bootstrap Search Bar

$(".btn-search").click(function(e) {
  $("#search-input, #btn-go").fadeToggle();
});
$(".hasclear").keyup(function() {
  var t = $(this);
  t.next('span').toggle(Boolean(t.val()));
});

$(".clearer").hide($(this).prev('input').val());

$(".clearer").click(function() {
  $(this).prev('input').val('').focus();
  $(this).hide();
});
body {
  height: 100%;
}
.banner {
  padding-bottom: 10px;
  text-align: center;
  background: white;
}
.banner img {
  height: 100px;
}
.navbar.navbar-custom {
  border: none;
  border-top: 6px solid #266080;
  border-bottom: 6px solid #266080;
  background: #444;
}
.navbar.navbar-custom .navbar-toggle {
  z-index: 1;
  border: none;
  background: none;
}
.navbar.navbar-custom .navbar-collapse {
  background: #444;
}
.navbar.navbar-custom .navbar-nav > li {
  border-left: 1px solid #fff;
}
.navbar.navbar-custom .navbar-nav > li:last-child {
  border-right: 1px solid #fff;
}
.navbar .formSearch {
  left: 0;
  position: absolute;
}
.navbar .formSearch .has-feedback span.glyphicon {
  padding: 7px;
  margin-right: 10px;
  cursor: pointer;
  pointer-events: auto;
  color: #fff;
}
.navbar .btn.btn-search,
.navbar .btn.btn-search:hover,
.navbar .btn.btn-search:focus {
  background: none;
  height: 50px;
  box-shadow: none;
  outline: none;
  border-radius: 0;
  border: none;
  color: #fff;
}
.navbar #search-input {
  height: 50px;
  background: #444;
  color: #fff;
  box-shadow: none;
  outline: none;
  font-size: 20px;
  border: none;
  display: none;
}
.navbar #search-input:focus {
  height: 50px;
  background: #444;
  color: #DFE82A;
  box-shadow: none;
  outline: none;
  font-size: 20px;
  border: none;
  display: none;
}
.navbar .input-group-btn #btn-go {
  height: 50px;
  border-radius: 0;
  border: none;
  box-shadow: none;
  outline: none;
  background: rgba(17, 18, 19, 1) color: #fff;
  display: none;
}
.well.well-dark {
  background: #444;
  border-radius: 0;
  color: #fff;
  text-align: center;
}
.footer {
  bottom: 0;
  width: 100%;
  height: 100px;
  background: #444;
  line-height: 85px;
  border-top: 6px solid #266080;
  border-bottom: 6px solid #266080;
}
ul.footer-nav > li {
  list-style: none;
  text-align: right;
}
ul.footer-nav > li > a {
  text-decoration: none;
  color: #fff;
}
/* Media Qs */

@media (min-width: 768px) {
  .navbar.navbar-custom .navbar-nav {
    width: 100%;
    text-align: center;
  }
  .navbar.navbar-custom .navbar-nav > li {
    float: none;
    display: inline-block;
  }
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<nav class="navbar navbar-inverse navbar-custom navbar-top">
  <section class="banner" id="banner">
    <img src="http://scottace.com/img/css3-icon.png">
  </section>
  <div class="container-fluid">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false"> <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>

      </button>
      <form class="formSearch" role="search"> <span class="input-group"> <span class="input-group-btn">
        <button class="btn btn-default btn-search" type="button"><span class="glyphicon glyphicon-search"></span>

        </button>
        </span>
        <div class="has-feedback">
          <input type="text" class="form-control hasclear" id="search-input" placeholder="Search for..."> <span class="clearer glyphicon glyphicon-remove form-control-feedback"></span>

        </div> <span class="input-group-btn">
        <button class="btn btn-default" id="btn-go" type="button"> Search</button>
      </span>
        </span>
    </div>
    </form>
  </div>
  <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
    <ul class="nav navbar-nav">
      <li><a href="#">Link</a>

      </li>
      <li><a href="#">Link</a>

      </li>
      <li><a href="#">Link</a>

      </li>
      <li><a href="#">Link</a>

      </li>
      <li><a href="#">Link</a>

      </li>
      <li><a href="#">Link</a>

      </li>
      <li><a href="#">Link</a>

      </li>
    </ul>
  </div>
  <!-- /.navbar-collapse -->
  </div>
  <!-- /.container-fluid -->
</nav>
<div class="container">
  <div class="well well-lg well-dark">
    <h1>Boostrap Search Bar</h1>

  </div>
  <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It
    has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
    publishing software like Aldus PageMaker including versions of Lorem Ipsum.Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer
    took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset
    sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's
    standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
    It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.Lorem Ipsum is simply dummy text of the
    printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries,
    but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker
    including versions of Lorem Ipsum.Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled
    it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages,
    and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since
    the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in
    the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.Lorem Ipsum is simply dummy text of the printing and typesetting
    industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic
    typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem
    Ipsum.Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
    It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
    publishing software like Aldus PageMaker including versions of Lorem Ipsum.Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer
    took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset
    sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's
    standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
    It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.Lorem Ipsum is simply dummy text of the
    printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries,
    but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker
    including versions of Lorem Ipsum.</p>
</div>
<footer class="footer">
  <div class="container">
    <ul class="footer-nav">
      <li><a href="#">Copyright &#169; 2015</a>

      </li>
    </ul>
  </div>
</footer>

关于javascript - Bootstrap 导航栏顶部的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32719762/

相关文章:

javascript - Raphael 沿着路径的 SVG 动画

javascript - 仅在 jquery 中输入数字

javascript - 检查字符串中的特定字符

java - 如何正确加载多个外部swf文件?

javascript - 使用 rowIndex 在单击的行下方插入新行

javascript - 通过 Vue.js 中的嵌套组件传递数据

javascript - 如何通过将视频 blob 转换为二进制数据包将其发送到 node.js 服务器?

javascript - 获取方法 javascript 传递 cookie

javascript - 如何保存网页以继续离线工作?

jquery - 我可以使用 Jquery UI 进入 Konva (Kineticjs) 阶段并保存到 JSON 字符串吗?