【问题标题】:css styles being ignored on second stylesheet在第二个样式表上忽略 CSS 样式
【发布时间】:2014-01-19 13:40:37
【问题描述】:

只是一个问题,无需代码调整!

所以我有一个主要的 'style.css' 并且在该文件中我使用了 '@import url("custom.css");'

我在top-container: margin-top:20px; 中有一个样式,但该网站不会显示更改..

如果我将 top-container: margin-top:20px; 移动到 style.css 中,它可以正常工作..

如果我添加 top-container: margin-top:20px!important; 也可以..

我不明白为什么样式会被忽略。

【问题讨论】:

  • 对我来说听起来像是一个特异性问题。将import 添加到样式表的底部。
  • 我认为 import 必须在顶部...不是吗?
  • 我的错 - 你是对的..developer.mozilla.org/en-US/docs/Web/CSS/@import 我建议在这里研究一下特异性是如何计算的:w3.org/TR/CSS2/cascade.html#specificity 您可能可以使选择器更具体。
  • CSS precedence的可能重复
  • 我想我明白了..在我的代码中我有一行 { margin 0 auto } 它隐藏在我身上......同时我在这段代码之前调用了 custom.css我的问题。

标签: html css styles stylesheet


【解决方案1】:

我想我想通了.. 在我的代码中我有一行 { margin 0 auto } 并且它隐藏在我身上......同时我在这段代码之前调用了 custom.css 这给了我问题。 -

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-14
    • 2020-11-26
    • 2010-10-31
    • 2011-09-29
    • 1970-01-01
    相关资源
    最近更新 更多