[英]Overriding a .class generated from a third party JS snippet to display: none; in a Gatsby JS site
Overriding a.class generated from a third party JS snippet to display: none;覆盖从第三方 JS 片段生成的 a.class 以显示:无; in a Gatsby JS site.
在 Gatsby JS 网站中。
Here is what I have thus far, located in the gatsby-browser.js file.这是我迄今为止所拥有的,位于gatsby-browser.js文件中。
export const onClientEntry = () => {
window.onload = () => {
document.addEventListener('DOMContentLoaded', function (event) {
document.getElementsByClassName('sc-7dvmpp-1 fprIlH').style.display = 'none';
});
};
};
The class I wish to override and display: none; class 我希望覆盖并显示:无;
<a type="link" href="https://example.com" class="sc-7dvmpp-1 fprIlH">Get Icon</a>
You can refer to that .sc-7dvmpp-1.fprIlH
class name to any SCSS (or CSS) file, even in CSS-in-JS .您可以将
.sc-7dvmpp-1.fprIlH
class 名称引用到任何SCSS(或 CSS)文件,即使在CSS-in-JS 中也是如此。 Just create a .scss
or .css
file and add:只需创建一个
.scss
或.css
文件并添加:
.sc-7dvmpp-1 .fprIlH {
display: none;
}
Import your file using:使用以下命令导入您的文件:
import "./yourFileName.css"
Note: this assumes that your file is in the same directory as your JavaScript component file.注意:这假设您的文件与 JavaScript 组件文件位于同一目录中。 Adapt it to your needs.
使其适应您的需求。
If the class name it's autogenerated and may change the name, use some kind of pseudoselector like:如果 class 名称是自动生成的并且可能会更改名称,请使用某种伪选择器,例如:
a[class^="sc-"] {
display: none;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.