【发布时间】:2016-05-21 02:27:44
【问题描述】:
我有两种风格,每种风格都在其单独的 3rd 方控件中声明,它们不能很好地配合使用,我什至不确定为什么会这样 - 最终 - 如何让它们按我想要的方式工作。
HTML:
<table>
<tr class="myrow">
<td>normal cell</td>
<td class="ui-state-error">error cell</td>
</tr>
</table>
CSS:
.myrow>td { /* declared in the grid component */
background-color: #88f;
}
.ui-state-error { /* declared in jQuery UI */
background-color: #f00;
}
HTML 和 CSS 都进行了简化以显示确切的错误。 Here's the fiddle.
这里的最终结果是两个单元格都显示蓝色背景 (FF 46.0)。
但是,我希望.ui-state-error 更具体,因为它直接应用于相关单元格,而.myrow>td 规则乍一看似乎更笼统。
无论如何,浏览器决定应用.myrow>td CSS,我想让它应用.ui-state-error。
考虑到 CSS 样式本身不受我控制,我该怎么做?
【问题讨论】:
-
如果您无法控制任一样式表,则不确定如何操作。根据 Alorika 的上述建议,您可能必须包含自己的样式表,该样式表专门覆盖它们
标签: html css css-specificity