要使用另一个类覆盖一个类的 CSS 属性,我们可以使用!important指令。在 CSS 中,!important 的意思是“这很重要” ,即使其他元素具有更高的特异性,也始终应用具有该指令的 property:value 对。
句法:
element1 {
property-x: value_y !important; /* This will be applied. */
}
element2 {
property-x: value_z; /* This will not be applied. */
}
例子:
!important
GeeksforGeeks
Cascading Style Sheets,
fondly referred to as CSS, is a simply designed language
intended to simplify the process of making web pages
presentable. CSS allows you to apply styles to web pages.
More importantly, CSS enables you to do this independent
of the HTML that makes up each web page.
输出: