javascript - 如何避免第三方CSS影响现有CSS?

标签 javascript jquery html css

<分区>


关闭 7 年前

在我的站点中,我正在使用 Jquery/Javascript 更改 DIV 的样式。同样的DIV样式,后来被第三方js库改了。有没有办法避免第三方样式更改。 我不允许使用 CSS 覆盖,因为 CSS 也是由不同来源编写的。

最佳答案

// your css
//// here use id and !important(hack)
#id1{ 
 color: blue !important;
}

// third party css class
.class1{
 color: red;
}

// your element
<input type="text" class="class1" id="id1"/>

输出: 颜色将为蓝色。你的CSS会赢。

阅读更多关于 CSS 的特殊性以更好地理解。

注意:Id 比 class 更具体。

关于javascript - 如何避免第三方CSS影响现有CSS?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32350526/

上一篇:css - Bootstrap 嵌套行边距顶部/底部

下一篇:jquery - 滚动条中断悬停状态,CSS

相关文章:

javascript - react : how to change page when using react-navigation and react-router?

Jquery 插件 filthypillow。如何将时间格式设置为 24 小时制

html - 什么会导致 bootstrap 列表现得像行?

JavaScript:如何添加属性?

javascript - setInterval 和 jquery

javascript - Raphaël 的响应式 SVG 折线图

jquery 不知道选择了什么选项

html - 如何使用 CSS 更改 iframe 页面而不更改父页面和外部链接

javascript - 什么是 <router-view :key ="$route.fullPath">?

javascript - 为什么我不能在 Angular ng-key 中使用动态