如果我有一个 classic.css
我想覆盖的文件(在这种情况下,它来自用于 Python 的 Sphinx 文档:https://docs.python.org/2.7/_static/classic.css)并且本质上是“撤消”规则,有没有办法做到这一点?
在这种情况下有这些规则:
div.sphinxsidebar h3 {
font-family: 'Trebuchet MS', sans-serif;
color: #ffffff;
font-size: 1.4em;
font-weight: normal;
margin: 0;
padding: 0;
}
div.sphinxsidebar h4 {
font-family: 'Trebuchet MS', sans-serif;
color: #ffffff;
font-size: 1.3em;
font-weight: normal;
margin: 5px 0 0 0;
padding: 0;
}
我想做的是类似
div.sphinxsidebar h3,
div.sphinxsidebar h4
{
font-family: [revert-to-auto];
color: [revert-to-auto];
}
所以我可以在 body
中指定字体系列和颜色无需使用 !important
即可应用到所有地方.
澄清一下:我有我的 custom.css
以 @import(classic.css);
开头根据 Sphinx 文档,而不是通常使用两个 <link rel="stylesheet" type="text/css">
<head>
中的元素部分。
最佳答案
是的,您可以使用 initial
恢复到 initial value该属性(property)的
div.sphinxsidebar h3,
div.sphinxsidebar h4
{
font-family: initial;
color: initial;
}
或 Cascade Level 4 介绍 revert
, 将级联回滚到用户级别
div.sphinxsidebar h3,
div.sphinxsidebar h4
{
font-family: revert;
color: revert;
}
关于css - 有没有办法覆盖 CSS 规则以从根本上否定它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38795601/