Inc*_*tor 5 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>
Run Code Online (Sandbox Code Playgroud)
有两件事可能导致这种情况
显而易见的是你应该删除第一个链接中的空格(看起来你已经编辑过了)
<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>