覆盖onesignal加载的CSS?我只是不明白

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

我想匹配一个单信号按钮以匹配我的网站样式。我将onesignal类与一个父ID结合在一起,它可以工作。

但是缺少了一些东西-因为在几秒钟之后按钮变大了,因为样式仍然被部分覆盖。


在文档中说:

要覆盖它们中的任何一个,您都必须创建具有更高特异性的CSS规则,将类名与父元素ID结合起来就足够了。但是请注意冲突,我们的内部风格可能会发生变化。

[他们的文档中还有更多的类,但是我似乎无法用“ button”和“ large”之类的样式来捕获它们-我也该如何捕获它们?

<style>
  #onesignal-style.onesignal-customlink-subscribe {
    color: #fff;
    width: auto;
    border-radius: 6px;
    text-decoration: none;
    display: inline-block;
    padding: 9px 36px 9px 36px;
    height: 60px;
    font-size: 16px;
    line-height: 24px;
    font-family: inter;
    font-weight: 600;
    text-align: center;
    background-color: #8f2df0;
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    -ms-flex-pack: center;
    justify-content: center;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    box-shadow: inset 0 0 20px 20px transparent;
    -webkit-transition: box-shadow 200ms ease;
    transition: box-shadow 200ms ease;
    text-transform: none;
  }
</style>
<div id="onesignal-style" class="onesignal-customlink-subscribe">Subscribe to Push</div>

这里是该项目的链接:

the onesignal documentation - about styling a custom prompt

this is my live testing website

html css overriding onesignal css-specificity
1个回答
0
投票

要覆盖all CSS,请使用HTML样式,如

h1{
    color: blue;
}
<h1 style="color: red">hello</h1>

以覆盖某些CSS样式,最后一个链接的CSS文档中的CSS。

例如,如果您首先链接了引导程序

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">

那么你有

<link rel="stylesheet" href="master.css">

您可以只使用master.css覆盖。

请注意,建议不要对html文档样式化,这是不正确的做法

© www.soinside.com 2019 - 2024. All rights reserved.