[英]How to link a CSS file in HTML file which is located in another folder
My link looks like this我的链接看起来像这样
<link rel="stylesheet" href="../styles/all.css" type="text/css" />
It is seen from the picture that path of the header.ejs
file is /views/partials/header.ejs
, while all.css
file located at styles/all.css
.从图中可以看出
header.ejs
文件的路径是/views/partials/header.ejs
,而all.css
文件位于styles/all.css
。 How to link these both files?如何链接这两个文件?
Change it to将其更改为
<link rel="stylesheet" href="../../styles/all.css" type="text/css" />
Explanation : If you go only one folder back from your header.ejs
file, you are in the folder views
.说明:如果您只从
header.ejs
文件返回一个文件夹,则您header.ejs
文件夹views
。 There is no styles
folder stored there.那里没有存储
styles
文件夹。 So you need to go one more folder back.所以你需要再返回一个文件夹。
I think you need to use我认为你需要使用
<link rel="stylesheet" href="../../styles/all.css" type="text/css" />
to go up to the personal_website directory before going to /style/all.css在转到 /style/all.css 之前转到 Personal_website 目录
Hope this helps :)希望这有帮助:)
<link rel="stylesheet" href="../../styles/all.css" type="text/css" />
That should work.那应该工作。
By "below" and "above", I mean subdirectories and parent directories. “下面”和“上面”是指子目录和父目录。 Relative file paths give us a way to travel in both directions.
相对文件路径为我们提供了一种双向传输的方式。 Take a look at my primitive example:
看看我的原始例子:
Here is all you need to know about relative file paths:以下是您需要了解的有关相对文件路径的所有信息:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.