简体   繁体   English

样式表中的类将覆盖CDN

[英]Classes in a stylesheet override CDN

I'm using Jquery UI (Dialog to be specific) 我正在使用Jquery UI(具体来说是对话框)

In my CSS (local) I have my custom class for example the input[type='text'] In CSS there are jQuery UI customizations to the input, but they are overwriting my. 在我的CSS(本地)中,我有我的自定义类,例如input[type='text']在CSS中,有针对输入的jQuery UI自定义,但是它们覆盖了我的自定义类。

How can I always keep the most suitable as my stylesheet? 如何始终保持最适合自己的样式表?

I've tried changing the order: 我尝试过更改顺序:

<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" />

But it always loads classes CDN. 但是它总是加载类CDN。

Will not you be using !important in all classes. 您不会在所有类中都使用!important吗?

Is there any way that he always give preference to my CSS file? 有什么办法可以让他始终优先使用我的CSS文件?

You can add more specificity to the CSS definition to override other definitions. 您可以为CSS定义添加更多特异性 ,以覆盖其他定义。

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


<div>
   <input type="text" ... />
</div>

Try being more specific with your query selector. 尝试使用查询选择器更具体。 So, if your input[type=text] is in a div, say 'div input[type=text]'. 因此,如果您的input [type = text]在div中,请说“ div input [type = text]”。 The most specific will always win. 最具体的总是赢。

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

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