2015-09-22 3 views

ответ

0

Вы можете создать изображение в навигационной панели, поскольку используете фиксированную позицию для навигации. Это сообщение может также помочь с другими функциями, похоже, вы пытаетесь реализовать: 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>

+0

Могу ли я использовать это, если navbar не был исправлен? Если нет, что мне нужно изменить? – John

+0

Хорошо, мне удалось заставить его работать без исправления! – John

+0

См. Этот ответ также для нефиксированного nav: http://stackoverflow.com/questions/32628502/bootstrap-3-centered-nav-and-image-behind/32643509#32643509 – vanburen

0

Не уверен в изображении, я бы не использовал процент для ширины, а затем vh для высоты, поскольку thia может вызвать искажение. Вставьте один и центрируйте его.

Однако ссылки могут использовать процентную ширину контейнера, в котором они находятся, чтобы они заполнили весь экран в соответствии с вашим дизайном.

+0

Хорошо, плохо, попробуйте изменить. Вы знаете, как я могу добавить те бары, которые находятся в дизайне? Те, что находятся в верхней части заголовка, внизу и над содержимым nav – John

+0

Сделайте два div один до и один после вашего изображения и дайте им ширину 100% и высоту, равную 10 пикселей, и сделайте цвет фона красным (или любым другим, что вы хотите) –

+0

Извините один между ссылками один за другим и перед изображением, затем поиграйте с высотой, чтобы получить то, что вы хотите –

Смежные вопросы