如何在不使用`!important`的情况下强制应用CSS? [英] How to force applying css without using `!important`?

查看:253
本文介绍了如何在不使用`!important`的情况下强制应用CSS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

主题的默认字体不支持我的语言,因此我通过在style.css上添加该字体来将其替换为支持的字体.

The default font of my theme doesn’t support my language, so I replace it with a supported one by adding this on the style.css

@font-face {    font-family: 'LibreBaskerville';
    src: url('https://xn--qucu-hr5aza.cc/wp-content/themes/the-thinker-lite-child/font/LibreBaskervilleF-Regular.ttf');
    url('https://xn--qucu-hr5aza.cc/wp-content/themes/the-thinker-lite-child/font/LibreBaskervilleF-Regular.woff') format('woff'); 
}

但是,一个插件仍使用默认字体:

However, one plugin still uses the default font:

我问过作者,他们说除了使用

* { font-family: "LibreBaskerville" !important;}

或复制主题的作用以覆盖它:

or copy what my theme is doing to override it:

html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {font-family: "LibreBaskerville";}

我发现这两种解决方案都不是问题的根源.有更好的方法吗?

I find both solutions don't get to the root of the problem. Is there a better way to do so?

推荐答案

如果您想选择手风琴中的所有内容,但又不想覆盖整个主题,则可以使选择器像这样

If you want to select everything inside the accordion, but not overwrite the entire theme with important, you can make your selector like this

.wp-block-kadence-accordion * { font-family: "LibreBaskerville"; }

这不太可能改变类名,但也不是不可思议的.

This is not likely to change in classnames, but not unthinkable either`

这篇关于如何在不使用`!important`的情况下强制应用CSS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆