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

标签 jquery html css bootstrap-4

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

Image of the Alert Box

我的警告框有以下代码:

<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;}

当我关闭警告框时,Font-Awesome 背景仍然可见! 我怎样才能防止这种情况发生? 插入一些:在 CSS 中的选择器之后?但是如何呢?

有好心人可以帮帮我吗?干杯。

最佳答案

这是因为在您的 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 选择器。

关于jquery - 单击关闭按钮后,如何删除警告框的基于 FontAwesome 的背景?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58695212/

相关文章:

jquery - 如何使用 jest 测试导入 jQuery UI 组件的 React 组件

javascript - 如何使用 jQuery 将元素与触发链接相关联?

jquery - 数据表编码 HTML

javascript - 模式窗口的 Bootstrap 下拉问题

html - 如何向 Material-UI 按钮添加数据属性?

html - 在 Internet Explorer 中将文本输入垂直居中

javascript - 如何使 slider 图像变暗?

javascript - 使用 slidetoggle() 隐藏特定高度的 div

javascript - 在手机上隐藏下拉菜单

css - 为什么我的负利润不会超过某个特定区域?