【发布时间】:2013-04-23 14:38:01
【问题描述】:
我第一次尝试 Bootstrap,我的代码基于他们的示例:
http://twitter.github.com/bootstrap/examples/starter-template.html
我基本上复制了主要内容的 html 代码,但在我的版本中,响应式导航栏不起作用,因为当我单击“汉堡按钮”时,导航元素不会出现。
我的代码:
<!DOCTYPE html>
<html>
<head>
<title>Bootstrap Test</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="css/bootstrap.css" rel="stylesheet" media="screen">
<link href="css/main.css" rel="stylesheet" media="screen">
</head>
<body>
<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><!--/.nav-collapse -->
</div>
</div>
</div>
<div class="container">
<h1>Hello, world!</h1>
</div> <!-- /container -->
<script src="http://code.jquery.com/jquery.js"></script>
<script src="js/bootstrap.js"></script>
</body>
</html>
我的引导文件来自 Bootstrap 自定义站点。我在构建中包含了所有内容,包括响应式导航栏。
我哪里错了。
谢谢大家。
更新
我删除了我的 main.css 文件,所以那里没有冲突。我再次尝试从自定义页面下载引导程序并勾选所有内容:twitter.github.com/bootstrap/customize.html,但仍然遇到同样的问题。它给我的 css 文件只是称为 bootstrap.css 而不是 bootstrap-combined.css。引导自定义页面有问题吗??
【问题讨论】:
-
你用的肯定是bootstrap-responsive.css文件吗?
-
该文件名为 bootstrap.css,它是从自定义引导页面下载的,并勾选了响应(实际上所有内容都勾选了)。
-
你还在为这个杰米工作吗?
-
我现在修好了。有趣的是,问题在于我使用的是在线 Cloud9 IDE,并且由于某种原因 Cloud9 没有提供任何 JS 文件。几个小时后我又试了一次,效果很好。