如何在本地覆盖全局CSS类

问题描述 投票:0回答:1

我为列表定义了一个全局变量,并在我的html中引用了

ol>li::before, ul>li::before {
color: #FFFFFF;
content: '\00A7';
display: inline-block;  
position: absolute;
}

我正在尝试在html中覆盖它,因为我必须删除此行:

content: '\00A7';

如果我只是在本地文件中使用它,它不会被覆盖。关于如何解决此问题的任何建议?

css global-variables overriding local
1个回答
1
投票

您有三种方法可以实现。

  1. 在您自己的CSS文件中的CSS之后添加!important
ol>li::before, ul>li::before {
content: '\00A7' !important;
} 
  1. 在HTML中的全局CSS之后添加CSS
<link rel="stylesheet" href="global.css">
<link rel="stylesheet" href="my.css">
  1. 在您的html元素中添加标签
<ol my-tag>
...
</ol>
ol[my-tag]>li::before{
    // your own css
}
© www.soinside.com 2019 - 2024. All rights reserved.