【问题标题】::before pseudo class not working:在伪类不起作用之前
【发布时间】:2017-10-07 10:22:26
【问题描述】:

在this page,我想在包含“ADSL 宽带 1”的灰色框上方添加一些文字。

我尝试使用以下 CSS 规则,但它不起作用:

.vc_tta-panels #adsl .vc_tta-panel-body:before {
    content: 'text goes here';
}

你能看看这里有什么问题吗?

【问题讨论】:

    标签: html css css-selectors pseudo-element


    【解决方案1】:

    您的其他规则覆盖此规则,您应该添加display 属性,例如:

    .vc_tta-panels #adsl .vc_tta-panel-body:before {
        content: 'text goes here';
        display: inline;
    }
    

    【讨论】:

    • 谢谢谢尔盖。我无法在深灰色框之前显示文本。我试过.vc_tta-panels #adsl .vc_tta-panel-body:before { content: 'text goes here'; display: block; line-height: 1.2; width: auto; height: auto; margin-bottom: 1em; }
    • @Steve 例如,您可以添加margin-top: -15px。
    【解决方案2】:

    您编写的代码运行良好,但与此同时,它被您在其他地方编写的CSS 隐藏了。

       vc_tta-panels #adsl .vc_tta-panel-body:before {
         content: 'Hello';
         display: block !important;
       }
    

    附上问题的快照,由于给出了display:none,它从那里被隐藏了。

    【讨论】:

    • 我无法在深灰色框之前显示文本。我试过.vc_tta-panels #adsl .vc_tta-panel-body:before { content: 'text goes here'; display: block; line-height: 1.2; width: auto; height: auto; margin-bottom: 1em; }
    猜你喜欢
    • 2021-08-21
    • 2012-07-31
    • 1970-01-01
    • 2018-06-02
    • 2021-08-06
    • 1970-01-01
    • 2017-05-27
    • 2012-10-25
    • 1970-01-01
    相关资源
    最近更新 更多