繁体   English   中英

在另一个文件夹中链接 a.css 文件

[英]Link a .css file in another folder

想象一下,我有一个文件夹“Website”,其中存储了该网站的文件,另一个文件夹为 fonts,并且字体文件夹为每种字体提供了更多文件夹。 我的html和css文件直接在网站文件夹里。 我的 font-face-css 文件位于 /font 文件夹中。

我想将我的 css 文件链接到我的 html 文件,所以我这样做:href="stylesheet.css"

我还想将我的 font-face-css 文件链接到我的 html 文件,那么我应该在 href="" 中放什么?

我还想链接我的 fonts,它们在它们自己的文件夹中,也在字体文件夹中,css 文件就是我的 font-face-css 文件,我应该在 src: 中放什么?

 1 Website folder
    1.1 Fonts folder (/fonts)
       1.1.1 Font1 folder (/fonts/font1)
             1.1.1.1 ttf file (/font/font1/font1.ttf)
             1.1.1.2 svg file (/font/font1/font1.svg)
       1.1.2 Font2 folder (/fonts/font2)
             1.1.2.1 ttf file (/font/font1/font2.ttf)
             1.1.2.2 svg file (/font/font1/font2.svg)
    1.2 html file (file.html)
    1.3 css file  (file.css)

检查此文件路径的快速提醒

这是您需要了解的有关相对文件路径的所有信息:

  • 以“ /”开头返回到根目录并从那里开始
  • 以“ ../”开头的目录向后移动并从该目录开始
  • 以“ ../../”开始向后移动两个目录,然后从那里开始(依此类推...)
  • 要前进,只需从第一个子目录开始,然后继续前进

我不清楚,您是否想将外部CSS链接为上面定义的文件结构? 如果是,则只需使用链接标记:

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

因此,基本上,对于网站文件夹(包含索引的文件夹)下的文件,您可以直接调用它。 对于每个连续的文件夹,在您的情况下都使用“ /”作为示例:

    <link rel="stylesheet" type="text/css" href="Fonts/Font1/file name">
    <link rel="stylesheet" type="text/css" href="Fonts/Font2/file name">

我想你想做的是

 <link rel="stylesheet" type="text/css" href="font/font-face/my-font-face.css"> 

 <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"> 
 .tree-view-com ul li { position: relative; list-style: none; } .tree-view-com .tree-view-child > li{ padding-bottom: 30px; } .tree-view-com .tree-view-child > li:last-of-type{ padding-bottom: 0px; } .tree-view-com ul li a .c-icon { margin-right: 10px; position: relative; top: 2px; } .tree-view-com ul > li > ul { margin-top: 20px; position: relative; } .tree-view-com > ul > li:before { content: ""; border-left: 1px dashed #ccc; position: absolute; height: calc(100% - 30px - 5px); z-index: 1; left: 8px; top: 30px; } .tree-view-com > ul > li > ul > li:before { content: ""; border-top: 1px dashed #ccc; position: absolute; width: 25px; left: -32px; top: 12px; } 
 <div class="tree-view-com"> <ul class="tree-view-parent"> <li> <a href=""><i class="fa fa-folder c-icon c-icon-list" aria-hidden="true"></i> folder</a> <ul class="tree-view-child"> <li> <a href="" class="document-title"> <i class="fa fa-folder c-icon" aria-hidden="true"></i> sub folder 1 </a> </li> <li> <a href="" class="document-title"> <i class="fa fa-folder c-icon" aria-hidden="true"></i> sub folder 2 </a> </li> <li> <a href="" class="document-title"> <i class="fa fa-folder c-icon" aria-hidden="true"></i> sub folder 3 </a> </li> </ul> </li> </ul> </div> 

当 css 在不同的文件夹中时,为无法找到将 css 链接到 html 的答案的所有人更新。 您只需要在 href 中的所有内容之前放置(点)。 我喜欢这个 href="./public/css/styles.css",但 main html index.html 我在主文件夹中有一切。 至少对我来说是这样。

暂无
暂无

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

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