我尝试在我的网页中包含两个引导菜单,一个垂直菜单和一个水平菜单,但布局被破坏了。这有什么解决方案吗? 这是我的水平菜单代码:
<html lang="en"><head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<!-- Bootstrap core CSS -->
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<!-- Fixed navbar -->
<div class="navbar navbar-default 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" href="home.php">Company</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="home.php"><i class="glyphicon glyphicon-home"></i><span> Home</span></a></li>
<li><a href="order.php"><i class="glyphicon glyphicon-pencil"></i><span> Order</span></a></li>
<li><a href="cart.php"><i class="glyphicon glyphicon-shopping-cart"></i><span> Cart</span></a></li>
<li><a href="contactus.php"><i class="glyphicon glyphicon-earphone"></i><span> Contact Us</span></a></li>
<li><a href="about.php"><i class="glyphicon glyphicon-search"></i><span> About Us</span></a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="register.php"><i class="glyphicon glyphicon-registration-mark"></i><span> Register</span></a></li>
<li class="active"><a href="login.php"><i class="glyphicon glyphicon-user"></i><span> Login</span></a></li>
</ul>
</div><!--/.nav-collapse -->
</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/1.11.1/jquery.min.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
</body>
</html>
这是我的垂直菜单代码。
<html lang="en"><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta name="generator" content="Bootply">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
<!-- CSS code from Bootply.com editor -->
<style type="text/css">
@media (min-width: 768px) {
.navbar-collapse {
height: auto;
border-top: 0;
box-shadow: none;
max-height: none;
padding-left:0;
padding-right:0;
}
.navbar-collapse.collapse {
display: block !important;
width: auto !important;
padding-bottom: 0;
overflow: visible !important;
}
.navbar-collapse.in {
overflow-x: visible;
}
.navbar
{
max-width:200px;
margin-right: 0;
margin-left: 0;
margin-top:200px;
}
.navbar-nav,
.navbar-nav > li,
.navbar-left,
.navbar-right,
.navbar-header
{float:none !important;}
.navbar-right .dropdown-menu {left:0;right:auto;}
.navbar-collapse .navbar-nav.navbar-right:last-child {
margin-right: 0;
margin-top:200;
}
}
</style>
</head>
<!-- HTML code from Bootply.com editor -->
<body>
<nav class="navbar navbar-default" role="navigation">
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse navbar-ex1-collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="breads.php">Breads</a></li>
<li><a href="cupcakes.php">Cupcakes</a></li>
<li><a href="pies.php">Pies</a></li>
<li><a href="pastas.php">Pastas</a></li>
<li><a href="desserts.php">Desserts</a></li>
<li><a href="caters.php">Caters</a></li>
</ul>
</div><!-- /.navbar-collapse -->
</nav>
</body></html>
然后我想把它包括在内。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Categories - Breads</title>
</head>
<body>
<?php include_once("hor_menu.php");?>
<?php include_once("vert_menu.php");?>
</body>
</html>
是否可以在不破坏布局的情况下包含这两个文件?
答案 0 :(得分:0)
尝试这样的事情(我没有测试过它)
<html lang="en"><head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<!-- Bootstrap core CSS -->
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
<style type="text/css">
@media (min-width: 768px) {
.navbar-collapse {
height: auto;
border-top: 0;
box-shadow: none;
max-height: none;
padding-left:0;
padding-right:0;
}
.navbar-collapse.collapse {
display: block !important;
width: auto !important;
padding-bottom: 0;
overflow: visible !important;
}
.navbar-collapse.in {
overflow-x: visible;
}
.navbar
{
max-width:200px;
margin-right: 0;
margin-left: 0;
margin-top:200px;
}
.navbar-nav,
.navbar-nav > li,
.navbar-left,
.navbar-right,
.navbar-header
{float:none !important;}
.navbar-right .dropdown-menu {left:0;right:auto;}
.navbar-collapse .navbar-nav.navbar-right:last-child {
margin-right: 0;
margin-top:200;
}
}
</style>
</head>
<body>
<!-- Fixed navbar -->
<div class="navbar navbar-default 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" href="home.php">Company</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="home.php"><i class="glyphicon glyphicon-home"></i><span> Home</span></a></li>
<li><a href="order.php"><i class="glyphicon glyphicon-pencil"></i><span> Order</span></a></li>
<li><a href="cart.php"><i class="glyphicon glyphicon-shopping-cart"></i><span> Cart</span></a></li>
<li><a href="contactus.php"><i class="glyphicon glyphicon-earphone"></i><span> Contact Us</span></a></li>
<li><a href="about.php"><i class="glyphicon glyphicon-search"></i><span> About Us</span></a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="register.php"><i class="glyphicon glyphicon-registration-mark"></i><span> Register</span></a></li>
<li class="active"><a href="login.php"><i class="glyphicon glyphicon-user"></i><span> Login</span></a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
<nav class="navbar navbar-default" role="navigation">
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse navbar-ex1-collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="breads.php">Breads</a></li>
<li><a href="cupcakes.php">Cupcakes</a></li>
<li><a href="pies.php">Pies</a></li>
<li><a href="pastas.php">Pastas</a></li>
<li><a href="desserts.php">Desserts</a></li>
<li><a href="caters.php">Caters</a></li>
</ul>
</div><!-- /.navbar-collapse -->
</nav>
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
</body>
</html>