无法连接Bootstrap样式表

时间:2015-06-29 15:21:36

标签: css twitter-bootstrap

我将简明扼要,因为我相信有一个快速解决我当前的问题。我使用空白模板使用bootstrap,由于某种原因我无法连接样式表?所有文件都位于同一目录中。由于不必要的挫折,我的耐心正在消瘦。如果你有任何答案或建议,他们会非常感激:)。我已在下面发布了HTML,谢谢!

贾斯汀

    <!DOCTYPE html>
<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">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <title>Justin A Henderson</title>

    <!-- Bootstrap -->
    <link href="../css/bootstrap.css" rel="stylesheet">

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  <body>
      <!---jumbotron--->
   <div class="jumbotron">
    <div class="container">
        <h1>Justin Henderson</h1>
    </div>
   </div>


    <!--nav-->
<ul class="nav nav-pills">
  <li role="presentation" class="active"><a href="#">Home</a></li>
  <li role="presentation"><a href="#">Profile</a></li>
  <li role="presentation"><a href="#">Messages</a></li>
</ul>


    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="js/bootstrap.min.js"></script>
  </body>
</html>

2 个答案:

答案 0 :(得分:1)

我们假设您的HTML文件名为justin.html,它位于名为site的文件夹中:

site
|
+-- justin.html

您的bootstrap CSS文件显示为..\css\bootstrap.css,其中显示:上一层,进入CSS文件夹,然后获取bootstrap.css,这意味着您需要以下目录结构它的工作原理:

<parent folder>
|
+-- css
|   |
+   +-- bootstrap.css
|
+-- site
    |
    +-- justin.html

但我打赌你的css文件夹实际上是 site,以及你的js文件夹,例如:

site
|
+-- css
|   |
|   +-- bootstrap.css
|
+-- js
|   |
|   +-- bootstrap.min.js
|
+-- justin.html

正确的路径是:

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

答案 1 :(得分:0)

看起来你的JS链接可能会链接得太远,请尝试:

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