简体   繁体   English

CSS文件位于上层目录中时,如何将HTML页面链接到CSS文件?

[英]How to link a HTML page to a CSS file when the CSS file is in an upper directory?

There is my problem: Since I had some organization issues with my website, I wanted to arrange my files to a better classification. 我的问题是:由于我的网站存在组织方面的问题,因此我希望将文件整理得更好。

Now, the folder tree looks like: 现在,文件夹树如下所示:

  • www 万维网
    • ressources ressources
      • images 图片
        • ... ...
      • css CSS
        • design.css design.css
    • mypage1 mypage1
      • index.html 的index.html
    • mypage2 mypage2
      • index.html 的index.html
    • index.html 的index.html

And now I don't know how to link the css file to the pages stored in a folder like the "mypage1" folder. 现在,我不知道如何将css文件链接到“ mypage1”文件夹之类的文件夹中存储的页面。 To start from my C: drive will will produce path errors once online, I tried the "shortcuts to the css file in each folder" solution too, but I think there is a far better way to proceed. 从我的C:驱动器启动后,一旦联机将产生路径错误,我也尝试了“每个文件夹中CSS文件的快捷方式”解决方案,但是我认为还有更好的方法。 Need some help! 需要一些帮助!

Thanks again! 再次感谢!

use the link: 使用链接:

<link type="text/css" rel="stylesheet" href="../ressources/css/design.css">

here, used ../ going back folder.. 在这里,使用../返回文件夹..

You can use: 您可以使用:

<link rel="stylesheet" href="../ressources/css/design.css" type="text/css" media="all">

The .. will go one directory top. ..将进入一个目录顶部。 Since the html files are in a directory (like mypage1 ), this will go to the parent directory, which is www . 由于html文件位于目录中(如mypage1 ),因此将转到父目录www Then the next that should be done is to pass the directory path to your CSS file, which in your case is /ressources/css/design.css . 然后,下一步是将目录路径传递到您的CSS文件,在您的情况下为/ressources/css/design.css

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

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