CSS外部工作表需要完整的路径链接而不是文件夹路径。为什么?

发布于 2025-02-11 01:12:56 字数 432 浏览 2 评论 0原文

代码的图片

与我的代码的第8行一样,我应该能够链接到样式我需要在附近的文件夹中。但是,那行不通,我需要完整的路径。

在我关注的在线课程中,讲师的工作方式除外,除了他们使用CSS/样式。CSS我认为,因为它们在Mac上。我做CSS \ styles.css,因为我在Windows上。

另外,即使我尝试在文件夹中更高,例如执行Web Development \ css \ styles.css.css,这也行不通。它只有在我一直回到C等时起作用。

更新:删除< html lang =“ en” dir =“ ltr”>修复了它,但是为什么呢?

有技巧吗?

Picture of code

As with line 8 of my code, I should be able to link to the style sheet I need in a neighboring folder. But, that doesn't work and instead I need the full path.

In the online course I'm following, the instructor has it work that way except that they use css/styles.css I think because they're on a mac. I do css\styles.css because I'm on windows.

Also, even if I try going higher in the folders like doing Web Development\css\styles.css, that doesn't work either. It only works when I go all the way back to C: and so forth.

UPDATE: deleting <html lang="en" dir="ltr"> fixed it, but why?

Any tips?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

粉红×色少女 2025-02-18 01:12:56

index.html文件中没有CSS文件夹,您可以使用..将文件夹向上转到文件夹,然后进入css文件夹并选择style.css文件。

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

there is no css folder adjacent to the index.html file, you can use .. to go folder up and then go into the css folder and select the styles.css file.

<link rel="stylesheet" href="../css/styles.css">
凶凌 2025-02-18 01:12:56

在您的代码中,没有像您的代码这样的文件路径尝试此路径
&lt; link rel =“ stylesheet” href =“/css/css.css”&gt;

in your code, there is no such file path like your code try this one
<link rel="stylesheet" href="/css/css.css">

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文