2

我正在使用 Bootstrap 3.0.0 创建一个站点,除了下拉菜单不起作用之外,一切都很好。在文件的头部,我做出了这样的声明:

<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0-rc1/css/bootstrap.css" rel="stylesheet">

<link href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet" />

<link href="http://fonts.googleapis.com/css?family=Abel|Open+Sans:400,600" rel="stylesheet" />

<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/bootstrap.js"></script>
<script type="text/javascript" src="js/dropdown.js"></script>

那里缺少什么?

html应该是正确的:

<li class="dropdown">
        <a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown-example<span class="caret"></span></a>
        <ul class="dropdown-menu">
          <li><a href="#link-1">link 1</a></li>
          <li><a href="#link-2">link 2</a></li>
          <li><a href="#link-3">link 3</a></li>
          <li><a href="#link-4">link 3</a></li>
        </ul>
      </li>

有谁知道该怎么做?

4

3 回答 3

2

jquery.js链接到您之前的外部 javascript 文件Bootstrap.js

<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/bootstrap.js"></script>
<script type="text/javascript" src="js/dropdown.js"></script>

您需要在使用之前加载 jQuery 。

于 2013-09-05T12:44:34.287 回答
1

I'm not sure but this scripts should be probably included at the end of html document

<script type="text/javascript" src="js/bootstrap.js"></script>
<script type="text/javascript" src="js/dropdown.js"></script>

Did you include jQuery too? Bootstrap plugins depend on this.

于 2013-09-05T10:13:21.563 回答
0

Just close the tag where you link to bootstrap.css. The "/" before the last angle bracket is missing in the code in your question. <link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0-rc1/css/bootstrap.css" rel="stylesheet" />

于 2013-11-24T16:53:50.547 回答