问题
This is what I'm trying to link into my HTML and it's not working I tried taking off the two periods and that doesn't work either.
<link rel="stylesheet" style="text/css" href="..CSS/file.css">
回答1:
In your case:
<link rel="stylesheet" style="text/css" href="../CSS/file.css">
More cases:
You can go up directories with ../
So for each ../
you will go up 1 directory
If you are in /public/files/
you can do
<link rel="stylesheet" style="text/css" href="../CSS/file.css">
to get into /public/CSS/
If you need to acces the root it could be:
<link rel="stylesheet" style="text/css" href="../../file.css">
to get into /
You can also link it from the current script directory:
<link rel="stylesheet" style="text/css" href="./CSS/file.css">
If you are in /public/files/
it would be /public/files/CSS/
And last from root to the directory:
<link rel="stylesheet" style="text/css" href="/public/CSS/file.css">
It would be /public/CSS/
and your file
回答2:
<link rel="stylesheet" style="text/css" href="../CSS/file.css">
回答3:
if you want to import css files to another css file use below syntax:
@import "url or path to file";
回答4:
<link rel="stylesheet" style="text/css" href="../../CSS/file.css">
Or use full url :
<link rel="stylesheet" style="text/css" href="://www.yoursite.com/file.css">
In full url, :// is instead specify http:// or https://
来源:https://stackoverflow.com/questions/43947600/how-do-i-link-a-css-stylesheet-from-another-folder-below-in-the-directory