Bootstrap CDN未加载

时间:2014-04-29 06:28:12

标签: html css twitter-bootstrap

一个简单而烦人的错误..我无法使用cdn加载Bootstrap css 这是简单的代码

         <html>
         <head>
<title>Header template</title>

<!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
    <!-- Optional theme -->
    <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap-theme.min.css">

    <!-- Latest compiled and minified JavaScript -->
    <script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>

      </head>
  <body>
<button class="btn btn-default">Hello World</button>
  </body>
  </html>

4 个答案:

答案 0 :(得分:9)

有两件事可能导致这种情况:

  • 显而易见的一点是你应该删除第一个链接中的空格(看起来你已经编辑过了)

    <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">

  • 您如何查看此文件?如果它不通过网络服务器提供(因此通过https的http),那么无协议链接将无法工作。 您的浏览器是否在地址栏中显示file:///等?然后在http://

  • 前添加//netdna.bootstrapcdn.com

<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css"> <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap-theme.min.css"> <script src="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>

答案 1 :(得分:1)

使用HTTP请求添加Href。使用它可以帮助您解决问题

<html>
         <head>
<title>Header template</title>

<!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
    <!-- Optional theme -->
    <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap-theme.min.css">

    <!-- Latest compiled and minified JavaScript -->
    <script src="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>

      </head>
  <body>
<button class="btn btn-default">Hello World</button>
  </body>
  </html>

答案 2 :(得分:1)

包含“http:”或“https:”部分只是一个传统问题,部分是实际指定协议的问题。如果是默认的,则使用当前页面的协议;例如,//www.example.com变为http://www.example.comhttps://www.example.com,具体取决于引用页面的URL。如果网页保存在本地磁盘上然后从那里打开,它就没有协议(只有文件:伪协议),所以像//www.example.com这样的网址不起作用;所以这是包含“http:”或“https:”部分的一个原因。

省略“//”部分完全是一个完全不同的问题,将URL转换为相对URL,该URL将被解释为相对于当前基本URL。

www.example.com在浏览器的地址行上输入或粘贴时的工作原因是相对URL在那里没有意义(没有基本URL可以关联),因此浏览器供应商决定暗示“http” ://“前缀那里。

答案 3 :(得分:0)

对我来说是日期和时间问题。我的日期和时间不正确,当我访问 cdn 链接时,我收到了日期和时间错误。改正后一切正常。

相关问题