我想更改 Wordpress 主题中的 css。我在 Wordpress 的 style.css
中添加了以下自定义 css。但是,我添加的样式并没有显示在网站上。我正在覆盖:
@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;
}
最佳答案
我想现在第一个 !important
正在覆盖你的第二个。但是您可以非常简单地覆盖 !important
语句
取自:How to override !important?
为选择器赋予更高的特异性(向选择器添加额外的标签、id 或类),或在比现有选择器更晚的位置添加具有相同选择器的 CSS 规则(在平局中,最后定义的获胜) ).
一些具有更高特异性的例子:
table td {height: 50px !important;}
.myTable td {height: 50px !important;}
#myTable td {height: 50px !important;}
或者在现有选择器之后添加相同的选择器:
td {height: 50px !important;}
免责声明: 使用 !important 几乎不是一个好主意。这是 WordPress 模板的创建者的糟糕工程。以病毒式传播的方式,它强制模板的用户添加他们自己的 !important 修饰符来覆盖它,并且它限制了通过 JavaScript 覆盖它的选项。
但是,如果有时需要,知道如何覆盖它是很有用的。
关于css - 改变 Wordpress 主题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34729667/