在我的HTML页面中包含引导程序

时间:2016-02-08 09:18:21

标签: javascript html css twitter-bootstrap

我有这么简单的代码行。我刚刚开始做一些Javascript编码,但我无法使这项工作。你能告诉我为什么吗?

<html>
<head>
    <script src="bootstrap.min.js"></script>
    <title>My Website</title>
</head>
<body>
    <p>This is an example of a paragraph.</p>
    <button type="button" class="btn btn-danger">Danger daw!</button>
</body>
</html>

页面上没有显示引导程序。

5 个答案:

答案 0 :(得分:3)

Bootsrap有Javascript,CSS和可选主题。从引导站点上的Getting Started链接,您可以获得以下代码,其中包含所有这些代码。 如果您自己托管文件,只需更新文件的路径即可。

<!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">

    <!-- Optional theme -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">

    <!-- Latest compiled and minified JavaScript -->
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>

答案 1 :(得分:0)

head标记之间添加此内容:

<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">

答案 2 :(得分:0)

你应该包含css文件路径,这里我使用了BootstrapCDN。并尝试从here了解bootstrap。我希望这有用。

  <html>
  <head>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
    <title>My Website</title>
 </head>
 <body>
   <p>This is an example of a paragraph.</p>
   <button type="button" class="btn btn-danger">Danger daw!</button>
</body>
</html>

答案 3 :(得分:0)

U miss incldue CSS

<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">

<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>

<!-- Latest compiled JavaScript -->
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>

答案 4 :(得分:0)

Bootstrap需要jquery作为依赖项。

使用rdn87

建议的以下代码
 <!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">
  <h1>Bootstrap</h1>
  <p>Text goes here</p>
</div>

</body>
</html>