【问题标题】:Classes in a stylesheet override CDN样式表中的类覆盖 CDN
【发布时间】:2011-07-28 11:06:18
【问题描述】:

我正在使用 Jquery UI(具体为对话框)

在我的 CSS(本地)中,我有我的自定义类,例如 input[type='text'] 在 CSS 中有对输入的 jQuery UI 自定义,但它们覆盖了我的。

我怎样才能始终保持最适合我的样式表?

我已尝试更改顺序:

<link href="https://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.12/themes/pepper-grinder/jquery-ui.css" type="text/css" rel="stylesheet"/>
    <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />

但它总是加载类 CDN。

你不会在所有类中都使用 !important。

有什么办法让他总是优先考虑我的 CSS 文件?

【问题讨论】:

    标签: html css overriding stylesheet cdn


    【解决方案1】:

    您可以在 CSS 定义中添加更多 specificity 以覆盖其他定义。

    <style>
       div input[type=text] { ... } // more specific, higher weight
       input                { ... } // less specific than previous definition
    </style>
    
    
    <div>
       <input type="text" ... />
    </div>
    

    【讨论】:

      【解决方案2】:

      尝试更具体地使用您的查询选择器。因此,如果您的 input[type=text] 在 div 中,请说“div input[type=text]”。最具体的总是会赢。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2013-01-12
        • 1970-01-01
        • 2020-09-21
        • 2012-03-05
        • 2018-11-22
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多