使用Twitter Bootstrap提供简单的响应式菜单

时间:2013-11-07 13:19:57

标签: jquery css twitter-bootstrap

我正在使用Bootstrap来创建一个响应的简单导航菜单,我已经按照一些教程,但是当我预览我的页面时,设计完全不同,设计没有响应。有人可以帮忙吗? 到目前为止,我的代码看起来像这样:

<head>
<meta charset="utf-8">
<title>Sara Cook</title>

<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Portfolio of my work">
<meta name="author" content="Sara Cook">

<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="css/bootstrap-responsive.css">
</head>

<body>
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-th-list"></span>
</a>
    <a href="#" class="brand">Sara Cook</a>
    <div class="nav-collapse colapse">
    <ul class="nav pull-right">
    <li class="active"><a href="#">Home</a></li>
    <li><a href="#">About</a></li>
    <li><a href="#">Portfolio</a></li>
    <li><a href="#">Contact</a></li>
    </ul>
  </div>
  </div>
  </div>
 </div>

<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.0.min.js"></script>
<script type="text/javascript" src="js/bootstrap.js"></script>

</body>

1 个答案:

答案 0 :(得分:0)

不要同时使用两者,

<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">

<强>被修改

我相信你正在使用Bootstrap 3,所以请尝试以下代码,同时参见fiddle

<div class="navbar navbar-fixed-top navbar-default">
    <div class="navbar-header"><a href="#" class="navbar-brand">Sara Cook</a><a class="navbar-toggle"
        data-toggle="collapse" data-target=".navbar-collapse">
<span class="glyphicon glyphicon-th-list"></span>
</a>
    </div>
    <div class="container">
        <div class="navbar-collapse colapse">
            <ul class="nav pull-right navbar-nav">
                <li class="active"><a href="#">Home</a>
                </li>
                <li><a href="#">About</a>
                </li>
                <li><a href="#">Portfolio</a>
                </li>
                <li><a href="#">Contact</a>
                </li>
            </ul>
        </div>
    </div>
</div>