【问题标题】:CSS file is linked but doesnt affect the pageCSS 文件已链接但不影响页面
【发布时间】:2016-08-27 13:19:21
【问题描述】:

我链接了css文件,在浏览器检查模式下我可以看到并打开它,但它不影响页面。

这是我的 layout.pug 文件:

  1 doctype html
  2 html
  3   head
  4     link(href="/stylesheets/app.css", type="text/css",  ref="stylesheet")
  5     block title
  6   body
  7     block content  

这是我的 index.pug 文件:

  1 extends layout
  2
  3 block title
  4   title Index
  5
  6 block content
  7   h1 Books
  8
  9   div
 10     a(href='new') New Book
 11
 12   table
 13     th Title
 14     th Author
 15     each book in books
 16       tr
 17         td= book.title
 18         td= book.author
 19         td (show)
 20         td (delete) 

这是我的 app.css 文件:

  1 h1 {
  2   color: blue;
  3 }

我错过了什么?为什么标题没有改变颜色?

【问题讨论】:

    标签: html css pug


    【解决方案1】:

    您可能希望在浏览器中检查您的文件并确保找到您的 css 文件。如果不检查您的拼写或文件的位置是否正确

    【讨论】:

      【解决方案2】:

      我发现的第一个错误是一个简单的错字:link 的属性是rel(不是ref)。

      引起我注意的另一件事(但只是怀疑)是关于href 属性:标题斜线正确吗?

      【讨论】:

      • 非常感谢。这是拼写错误(rel)。你只是让我坐在这里抱着头 2 个小时尝试了所有可能的路径。再次感谢您。
      猜你喜欢
      • 2021-04-04
      • 2014-06-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-06
      • 2015-03-28
      相关资源
      最近更新 更多