【发布时间】:2020-06-30 04:26:02
【问题描述】:
我已经尝试了HTML not loading CSS file 中的所有方法,但它们似乎不起作用。当我试图检查 chrome 上的元素时,他们告诉我
“加载资源失败:net::ERR_FILE_NOT_FOUND”。
这是我的文件结构
C>DevProject>index.html
在我的 index.html 中有两项,一项是“索引”,它是我的 HTML 文件夹,单击它会打开网站。另一个项目“样式”是我的 CSS 文件,点击它会打开带有代码的记事本
这里是代码
<!DOCTYPE html>
<html>
<head>
<title>Test Title</title>
<link href="/style.css/"type="text/css" rel="stylesheet">
</head>
<body>
<h1>H1 text</h1>
<p>I'm learning to code on Codecademy! My goals include:</p>
<ul>
<li>Goal 1</li>
<li>Goal 2</li>
<li>Goal 3</li>
</ul>
</body>
</html>
这是 CSS 代码
* {
font-family: Helvetica, Arial, sans-serif;
}
h1 {
color: SeaGreen;
}
p,
li {
font-size: 18px;
}
a {
text-decoration: none;
}
我也尝试过更改为href="DevProject/index.html/style.css/",但是通过 VS 代码“关注链接”给了我
无法读取文件'c:\DevProject\index.html\DevProject\index.html\style.css\
我确保编码是 UTF-8
我也尝试过分离 CSS 和 HTML 文件,例如
Devproject>style.css>style
但同样的错误
【问题讨论】:
-
试试
href="style.css"