简体   繁体   English

从继承中排除CSS类

[英]Exclude CSS class from inheriting

I have tried to search but am not sure if I am posing the question right. 我已经尝试搜索,但是不确定我是否提出正确的问题。

I applied the following css to my site: 我将以下CSS应用于我的网站:

a[target='_blank']::after {
    content: '\29C9';
}

This means that all external links will get the icon attached to it. 这意味着所有外部链接都将附有图标。 So far, so good, it works as expected. 到目前为止,一切都很好,它按预期工作。

There are some situations though where I do not want this to happen, like in social share buttons. 在某些情况下,我不希望这种情况发生,例如在社交分享按钮中。 How can I exclude some classes? 如何排除某些班级?

Like when the link appears in a div with class ' socialbutton '? 就像链接出现在具有“ socialbutton ”类的div中时一样?

PS I cannot add other style to these buttons (WordPress website and generated code) PS我不能向这些按钮添加其他样式(WordPress网站和生成的代码)

You can overwrite this css code by adding new css to the class. 您可以通过向类添加新的CSS来覆盖此CSS代码。

Example you can overcome this: 您可以克服以下示例:

a[target='_blank']::after {
    content: '\29C9';
}

By doing this: 通过做这个:

.socialbutton::after {
    content: '\fff' !important;
}

You can use the :not() selector: 您可以使用:not()选择器:

a[target='_blank']:not(.social)::after {
    content: '\29C9';
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM