【发布时间】:2019-09-26 16:21:29
【问题描述】:
我想在我的 WP 网站上的一个菜单项中添加一个通知圈。
样式是在 css 中完成的,现在它必须放在不存在的 <span> 标记中。
<span> 必须放在 <a> 标记之后才能工作。
我的方法是使用 ::after 但我似乎无法让代码工作。
我做错了什么?
我尝试了很多变化,但没有成功。
这不起作用:
a::after {
content: "<span class="notifier">3</span>";
}
.notifier {
position: absolute;
top: 1.25rem;
right: -0.5rem;
background: #ea3326;
width: 1.25rem;
height: 1.25rem;
text-align: center;
line-height: 1.225rem;
color: #ffffff;
font-weight: bold;
border-radius: 100%;
z-index: 97;
font-size: 0.8rem;
cursor: pointer;
}
以下也不起作用。但是它在前端显示代码<span class="notifier">3</span>,而不是样式。
a::after {
content: "<span class=\"notifier\">3</span>";
}
.notifier {
position: absolute;
top: 1.25rem;
right: -0.5rem;
background: #ea3326;
width: 1.25rem;
height: 1.25rem;
text-align: center;
line-height: 1.225rem;
color: #ffffff;
font-weight: bold;
border-radius: 100%;
z-index: 97;
font-size: 0.8rem;
cursor: pointer;
}
我希望按钮旁边有一个带有白色 3 的红色圆圈。
【问题讨论】:
标签: css-selectors