jquery - 单击关闭按钮后,如何删除基于 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;}
当我关闭警告框时,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
选择器。
推荐阅读
- multithreading - 不兼容的类型:“常规过程和方法指针”
- java - Java - 单词加扰器[保留第一个和最后一个字母]
- java - 如何扩展 ConnectionService?
- java - 获取多个 Element JSoup Java Android
- ios - 从 iOS 上的 React Native 应用程序访问 NSUserDefaults
- nrules - NRules 会议如何比较事实?
- amazon-web-services - AWS 访问密钥与密钥对
- ruby - 如何在两个字符/子字符串之间提取子字符串
- azure-data-factory-2 - Azure 数据工厂 V2 集 AzureRmDataFactoryV2Dataset:“表名”不能为空
- elasticsearch - 带有变量的弹性搜索查询脚本