我是 HTML 的新手,我正在尝试在我的元素中使用 bootstrap。
问题是我无法加载 bootstrap.min.css 并且所有类都不起作用。我做了一些搜索并尝试了一些方法,但它们对我不起作用
这是我的代码:
<!DOCTYPE html>
%{--<!doctype html>--}%
<html>
<head>
<meta charset = "utf-8">
<meta http-equiv = "X-UA-Compatible" content = "IE = edge">
<meta name = "viewport" content = "width = device-width, initial-scale = 1">
%{--<link href="bootstrap.min.css" rel="stylesheet" media="screen">--}%
<link rel="stylesheet" href="E:\TekDays\web-app\bootstrap-3.3.7-dist\css\bootstrap.min.css" type="text/css">
<title>TekDays - The Community is the Conference!</title>
</head>
<body>
<div class="container">
<table class="table table-bordered">
<thead>
<tr>
<th>FirstName</th>
<th>FirstName</th>
</tr>
</thead>
<tr>
<td>Mammad</td>
<td>mammadii</td>
</tr>
<tr>
<td>Akbar</td>
<td>Akbarii</td>
</tr>
</table>
</div>
</body>
</html>
- 使用绝对路径会导致错误(使用 f12):不允许加载本地资源:file:///E:/TekDays/web-app/bootstrap-3.3.7-dist/css/bootstrap.min。 CSS
我在某处读到这只是 chrome 的错误而 Edge 或 IE 浏览器没有这个问题,它们没有但结果是一样的,没有应用 css 类。
- 我将 bootstrap.min.css 放在与我的 html 页面相同的目录下并使用
<link href="bootstrap.min.css" rel="stylesheet" type="text/css" media="screen">
而不是代码中使用的内容。
但是这次我得到错误 404: not found 这似乎是我给出的路径的问题......但我不知道该怎么做
知道它有什么问题吗?
最佳答案
这里使用的斜线
<link rel="stylesheet" href="E:\TekDays\web-app\bootstrap-3.3.7-dist\css\bootstrap.min.css" type="text/css">
会导致用户浏览器从他的文件系统访问文件。
改变路径
<link rel="stylesheet" href="E:/TekDays/web-app/bootstrap-3.3.7-dist/css/bootstrap.min.css" type="text/css">
更新的答案: Resource not found Error and what about resources plugin
关于html - 无法加载 CSS 样式表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39093797/