How do I link a CSS stylesheet from another folder below in the directory?

时间秒杀一切 提交于 2019-12-13 07:33:33

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!