我想只有在附加点击元素:在以下小提琴after伪元素:附加事件
<div class="tag deletable", style="style")>
Tagname
</div>
.tag {
display: inline-block;
background: white;
padding: 3px 6px;
line-height: 1em;
border-radius: 4px;
font-size: 12px;
border-right: 5px solid;
}
.deletable {
border-right: 18px solid;
position: relative;
}
.deletable:after {
content: "\D7";
position: absolute;
color: white;
right: -12px;
top: 3px;
font-size: 12px;
cursor: pointer;
}
https://jsfiddle.net/x2ztqdbm/
但似乎是不可能的。有没有办法实现这一点? 如果没有,有人可以帮我重写HTML代码,以便不使用伪元素吗?重要的是:after部分永远不会中断到下一行。
在此先感谢。
这是一个有点不清楚你想要达到的目标。伪元素究竟应该做什么?通过“附加事件”你是指JS中的'click'事件吗? – VilleKoo
?你可以这样做https://jsfiddle.net/x2ztqdbm/3/ –