繁体   English   中英

无法将index.html文件链接到另一个文件夹中的style.css文件

[英]Cannot link index.html file to style.css file in another folder

我正在尝试将style.css文件链接到index.html文件。 这两个文件位于单独的文件夹中。

资料夹结构:

/父母

  • /src/index.html
  • /css/style.css

我尝试使用的代码:

<link rel="stylesheet" type="text/css" href="../css/style.css">
<link rel="stylesheet" type="text/css" href="./css/style.css">
<link rel="stylesheet" type="text/css" href="/css/style.css">
<link rel="stylesheet" type="text/css" href="css/style.css">

我不断进入终端的相同错误:

GET /css/style.css 404 1.542毫秒-152

我在实时服务器上使用VS Code。

注意:当我将index.html文件放在src文件夹之外的父文件夹中时。 路径href =“ css / style.css”有效。

在Root /parent启动实时服务器 ,然后导航至/src/index.html 如果从包含index.html的目录开始,则不能向上移动。

您的href看起来应该像这样:href =“ style.css”

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM