简体   繁体   English

为什么我的CSS文件没有链接到我的HTML文件?

[英]Why is my CSS file not linking to my HTML file?

Here is the path I am working with - /public_html/websystems/websystems.css 这是我正在使用的路径-/ /public_html/websystems/websystems.css

The HTML file I am trying to link is in the public_html directory and named index.html 我要链接的HTML文件位于public_html目录中,名为index.html

The CSS file I am trying to link is in the websystems directory and named websystems.css 我要链接的CSS文件位于websystems目录中,名为websystems.css

The contents of the files are shown in the images below. 文件的内容如下图所示。

HTML file HTML文件 在此处输入图片说明

CSS file CSS文件 在此处输入图片说明

Why are none of the styles I've set in my CSS file applying to my HTML file? 为什么我在CSS文件中设置的所有样式都无法应用于HTML文件?

Thanks for your help. 谢谢你的帮助。

Try this, 尝试这个,

websystems/websystems.css


Note that, (taken from Quick Reminder About File Paths ) 请注意, (摘自关于文件路径的快速提醒

  • Is the image in the same directory as the file referencing it? 映像是否与引用该文件的目录位于同一目录中?
  • Is the image in a directory below ? 图像是否在下面的目录
  • Is the image in a directory above ? 图像是否在上面的目录中?

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: 这是您需要了解的有关相对文件路径的所有信息:

  • Starting with "/" returns to the root directory and starts there 以“ /”开头返回到根目录并从那里开始
  • Starting with "../" moves one directory backwards and starts there 以“ ../”开头的目录向后移动并从该目录开始
  • Starting with "../../" moves two directories backwards and starts there (and so on...) 以“ ../../”开始向后移动两个目录,然后从那里开始(依此类推...)
  • To move forward, just start with the first subdirectory and keep moving forward 要前进,只需从第一个子目录开始,然后继续前进

Change the /websystems/websystems.css to just websystems/websystems.css and see if that works. /websystems/websystems.css更改为/websystems/websystems.css websystems/websystems.css ,看看是否websystems/websystems.css That's a path relative to the current path of index.html . 这是相对于index.html当前路径的路径。

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

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