单击关闭按钮后,如何删除基于FontAwesome的警报框背景?

我的网站上有一些警报框。当有人单击警报框右上角的关闭按钮时,我需要基于FontAwesome的背景消失。

单击关闭按钮后,如何删除基于FontAwesome的警报框背景?

我的警报框具有以下代码:

<div id="system-message">
    <div class="alert alert-notice">
        <a class="close" data-dismiss="alert" aria-label="">×</a>
        <h4 class="alert-heading">Warning</h4>
            <div>
              <div>blah blah blah.</div>
            </div>
    </div>
<div>

创建背景的代码是这样的:

div#system-message:before {
    position: absolute; top: 30px; right: 100px;
    font-family: FontAwesome;
    font-weight: normal;
    font-style: normal;
    display: inline-block;
    text-decoration: inherit;
    font-size: 72px;
    line-height: 1;
    opacity: .1;
  content: "\f00c"; z-index: 1;}

当我关闭警报框时,“超赞”背景仍然可见! 我该如何预防? 在CSS中的选择器之后插入一些:但是如何?

外面有什么友善的灵魂可以帮助我吗?干杯。

wuhao1972 回答:单击关闭按钮后,如何删除基于FontAwesome的警报框背景?

这是因为背景在您的CSS中附加到作为父元素的#system-message上。您必须按照以下步骤更改代码:

div#system-message>alert:before {
    position: absolute; top: 30px; right: 100px;
    font-family: FontAwesome;
    font-weight: normal;
    font-style: normal;
    display: inline-block;
    text-decoration: inherit;
    font-size: 72px;
    line-height: 1;
    opacity: .1;
  content: "\f00c"; z-index: 1;}

如果您不想在每个警报中重复背景,可以添加:first-child选择器。

本文链接:https://www.f2er.com/3166105.html

大家都在问