我正在使用bootstrap导航栏,一切都很好,但是当我在php上调用include函数来调用导航栏时,我看到页面顶部和导航栏之间存在间隙。发生了什么事?
这是index.php
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="assets/css/bootstrap.css" rel="stylesheet">
<style type="text/css">
body {
padding-top: 60px;
padding-bottom: 40px;
}
.sidebar-nav {
padding: 9px 0;
}
@media (max-width: 768px) {
body {
padding-top: 0;
}
}
</style>
<link href="assets/css/bootstrap-responsive.css" rel="stylesheet">
这是navbar.php:
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="brand" href="#">Project name</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</div>
</div>
当我在index.php中调用时:
<?php include('navbar.php'); ?>
导航栏和首页之间有一个空格。如果我将导航栏代码粘贴到index.php
,一切都会顺利。