我想在Wordpress主题中修改css。我正在添加以下自定义css在style.css中的Wordpress。但是,我添加的样式并没有出现在网站上。我要覆写:
@media screen and (max-width: 830px)
.masthead .top-bar, .masthead .hide-on-mobile {
display: none !important;
}至
@media screen and (max-width: 830px)
.masthead .top-bar, .masthead .hide-on-mobile {
display: inline !important;
}发布于 2016-01-11 19:46:55
现在,我想第一个!important正在覆盖您的第二个。但是您可以很简单地重写!important语句
摘自:How to override !important?
赋予选择器更高的特异性(向选择器添加额外的标记、id或类),或者在比现有的选择器晚一点添加CSS规则(在tie中,最后定义的选择器获胜)。
一些具有较高特异性的例子:
table td {height: 50px !important;}
.myTable td {height: 50px !important;}
#myTable td {height: 50px !important;}或在现有的选择器之后添加相同的选择器:
td {height: 50px !important;}免责声明:这几乎不是一个好主意,使用!重要。这是WordPress模板的创建者的糟糕工程。以病毒的方式,它强制模板的用户添加他们自己的!重要的修饰符来覆盖它,并且它限制了通过JavaScript重写它的选项。
但是,知道如何重写它是很有用的,如果你有时不得不这样做的话。
https://stackoverflow.com/questions/34729667
复制相似问题