繁体   English   中英

如果我的 HTML 文件位于子目录的子目录中,而我的 CSS 位于 styles 文件夹中,如何将 html 文件与 CSS 文件链接?

[英]How do I link an html file with a CSS file if my HTML file is in a sub directory of a subdirectory and my CSS is in the styles folder?

我开始了 Free Code Camp 项目,但我无法将 CSS 文件与 HTML 链接起来,我确信我错过了眼前的东西,但我无法弄清楚。

这是我的文件夹的结构:带有 index.html 的根文件夹,

一个名为 site-content 的文件夹,

另一个名为 styles,

图片

和脚本。

在 site-content 文件夹中,我有另一个名为 projects 的文件夹。

在该文件中,我有 tribute.html 页面。

我想要做的是将我的 tribute.css 连接到 tribute.html。

这是它的样子:

<link href="styles../../../tribute.css" rel="stylesheet">

或: <link href="../../../styles/tribute.css" rel="stylesheet">我试过../ 或什至./,我从 1 添加到 5../ 但它仍然不起作用,我迷路了。 我究竟做错了什么? 谢谢。

如果我理解你的文件树是这样的:

|-index.html
|--site-content-|
|               |--projects--|
|                            |--tribute.html
|
|--styles-------|
|               |--tribute.css
|--Images
|--Scripts

从“tribute.html”到 go 到“tribute.css”的路径是“../../styles/tributes.css”

<link href="../../styles/tribute.css" rel="stylesheet">应该有效

我建议你做一些关于 relative 和 asbolute 路径的研究,以便更好地理解它

暂无
暂无

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

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