1

我正在使用创建 Web 应用程序,linemanjs但是当我明确引用供应商cssjs文件时,它不会引用该位置。让我知道我在 linemanjs 上做错了什么。

我在文件中尝试过的简单事情是 -

link(rel="stylesheet",href="/vendor/css/myvendor.css")

link(rel="stylesheet",href="/css/myvendor.css")

link(rel="stylesheet",href="css/myvendor.css")

->myvendor.css肯定位于 vendor 下的 css 文件夹中。

4

1 回答 1

2

因为不使用基本 HTML 的基本标记:

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

如果必须是服务器或客户端,则必须包含标签的路径。

如果文件夹vendor包含所有文件 html 和包含您用于站点的文件的文件夹,则我之前包含在标记中的路径是正确的。

如果仍然不包含此文件css,则问题是文件不存在或声明错误的文件名或结构 css 错误(最好发布文件 css)但我认为您发现Inspect ElementFirebug的问题(附加对于 Firefox 和 [也许] Chrome)

更新:啊,如果您使用 Jade,'type='text/css'请在您的标签内添加,因为您最好定义文件类型。

link(rel='stylesheet', href='css/myvendor.css', type='text/css' )

阅读JADE等文档

Template inheritance

If you have multiple views with a similar structure, you will end up with the same set of includes in all your views. This approach can quickly become complicated and untidy, if the number of views and includes increases.

使用 Jade,您可以生成包含 css 文件的标签:

!!! 5
html
    head
        title Learning Inheritance
        link(rel='stylesheet', href='/css/myvendor.css')
    body
!!!

或者在 StavkoverFlow 上的其他问题中发布了其他解决方案

head
  title test include
  | <style type='text/css'>
  include css/myvendor.css
  | </style>
于 2014-07-18T09:45:51.603 回答