我想只有在附加點擊元素:在以下小提琴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/ –