html - 未找到与 HTML 位于同一文件夹中的 CSS 文件
问题描述
这是一个非常基本的问题,但在过去的一周里,我一直在努力解决这个问题。我刚开始将 CSS 添加到我的项目中,并将 base_style.css 链接到 base.html。由于某种原因,服务器找不到 base_style.css。
基础.html:
<head>
<title> Chat </title>
<link href = "base_style.css" type = "text/css" rel = "stylesheet">
</head>
base_style.css:
h1 {
text-align: center;
}
但是,当我通过命令提示符运行服务器时,我得到:
[21/Aug/2020 23:35:25] "GET / HTTP/1.1" 200 517
Not Found: /base_style.css
[21/Aug/2020 23:35:25] "GET /base_style.css HTTP/1.1" 404 5153
即使通过 base_style.css 和 base.html 在同一个文件夹/目录中:
08/18/2020 07:48 PM <DIR> .
08/18/2020 07:48 PM <DIR> ..
08/21/2020 11:24 PM 584 base.html
08/21/2020 11:24 PM 51 base_style.css
08/17/2020 12:05 AM 622 chatroom.html
08/13/2020 05:03 PM 418 chatrooms.html
08/15/2020 09:53 PM 376 edit_message.html
08/13/2020 05:00 PM 295 index.html
08/13/2020 05:06 PM 272 new_chatroom.html
08/14/2020 04:00 PM 378 new_message.html
8 File(s) 2,996 bytes
2 Dir(s) 417,867,866,112 bytes free
如果有人知道发生了什么,我将不胜感激。
解决方案
尝试使用相对路径:
<link href = "./base_style.css" type = "text/css" rel = "stylesheet">
推荐阅读
- machine-learning - 堆叠分类器上的分类器数量是否必须等于我的训练/测试数据集的列数?
- javascript - 使用 React-Native 推送通知
- video - ffmpeg 在 Windows Media Player 上拆分视频 H264 口吃
- php - RSS 到 JSON 转换器似乎并不总是有效
- elasticsearch - Kubernetes + ELK : 将 kibana 连接到 elasticsearch 服务
- bash - conda环境中的bash别名
- python - pyrebase.storage() - 无效的 HTTP 方法/URL 对
- python - 用另一个字典中的项目替换字典中列表中的项目
- java - 登录时用户出错并且他不在数据库中
- java - 保存 WebView 并在离线时显示它?