@Bhanu pratap解决了这个问题。在这个问题的最后检查出来。
我一直在按照旧课程建造导航栏崩溃(三明治)。 问题是课程中的页面顶部显示黑条,缩小页面时会出现导航栏。对我来说,我只是左边有一个按钮。此外,当我缩小页面时,我无法获得导航栏。
这是源代码:
<!DOCTYPE html>
<html lang="arabic">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" herf="assets/img/favicon.ico">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="assets/js/jquery-3.1.1.min.js"></script>
<script src="assets/js/main.js"></script>
<!-- Bootstrap core CSS -->
<link href="assets/css/bootstrap.min.css" rel="stylesheet">
<!-- Font-Awesome icons-->
<link href="assets/css/font-awesome/css/font-awesome.min.css">
<!-- Google Fonts LATEEF -->
<link href="https://fonts.googleapis.com/css?family=Changa:400,600&subset=arabic,latin-ext" rel="stylesheet">
<title>Bootstrap to Wordpress</title>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<!-- HEADER -->
<header class="site-header" role="banner">
<!-- NAVBAR -->
<div class="navbar-wrapper">
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" herf="/"><img src="assets/img/logo.png" alt="Bootstrap to WordPress"></a>
</div><!-- navbar-header -->
<div class="navbar-collapse collapse">
</div><!-- collapse nav-->
</div><!-- container -->
</div><!-- navbar -->
</div><!-- navbar-wrapper-->
</header>
<!-- FOOTER TAG -->
<footer>
</footer>
<!-- MODAL -->
<div>
</div>
<!-- BOOTSTRAP CORE JAVASCRIPT
PLACED AT THE END OF THE DOCUMENT SO THE PAGES
LOAD FASTER!
================================================== -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="assets/js/jquery-3.1.1.min.js"></script>
<script src="assets/js/main.js"></script>
<!-- Type google font -->
<script src="https://use.typekit.net/byz5vqz.js"></script>
<script>try{Typekit.load({ async: true });}catch(e){}</script>
</body>
</html>
我尝试使用其他源代码更改此部分,但问题又出现了。
<!-- NAVBAR -->
<div class="navbar-wrapper">
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" herf="/"><img src="assets/img/logo.png" alt="Bootstrap to WordPress"></a>
</div><!-- navbar-header -->
<div class="navbar-collapse collapse">
</div><!-- collapse nav-->
</div><!-- container -->
</div><!-- navbar -->
</div><!-- navbar-wrapper-->
更新: @Bhanu pratap通过addin ul和li解决了问题,以显示可见效果。这是他的源代码:
<script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="navbar-wrapper">
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" herf="/"><img src="assets/img/logo.png" alt="Bootstrap to WordPress"></a>
</div><!-- navbar-header -->
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>
<a href="">First Menu Item</a>
</li>
<li>
<a href="">Second Menu Item</a>
</li>
<li>
<a href="">Third Menu Item</a>
</li>
</ul>
</div><!-- collapse nav-->
</div><!-- container -->
</div><!-- navbar -->
</div>
答案 0 :(得分:1)
试试这个..我刚刚在您的代码中添加了ul和li以显示可见效果,您可以在那里使用您的代码部分..
<script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="navbar-wrapper">
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" herf="/"><img src="assets/img/logo.png" alt="Bootstrap to WordPress"></a>
</div><!-- navbar-header -->
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>
<a href="">First Menu Item</a>
</li>
<li>
<a href="">Second Menu Item</a>
</li>
<li>
<a href="">Third Menu Item</a>
</li>
</ul>
</div><!-- collapse nav-->
</div><!-- container -->
</div><!-- navbar -->
</div>
答案 1 :(得分:0)
$(document).on('click','.navbar-collapse.in',function(e) {
if( $(e.target).is('a') && ( $(e.target).attr('class') != 'dropdown-toggle' ) ) {
$(this).collapse('hide');
} });
$("button.navbar-toggle").click(function (e) {
$("#main-navbar").collapse('hide');
$("#main-navbar").removeClass("in"); });