You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何移除最后一个.note-right small的::after伪元素双换行?

问题描述

我有一组笔记,通过为.note-right small元素添加::after伪元素实现末尾双换行,代码如下:

.note-right small::after { 
  content: "\a\a";
  white-space: pre
 }

现在我希望最后一个笔记末尾无换行,尝试使用以下代码但无效:

.note-right small:last-child { 
   content: none;
  }

请问我遗漏了什么?

解决方法

你写错了选择器——你当前的代码是针对最后一个small元素本身设置content,但content属性仅对伪元素生效,且我们要修改的是small的::after伪元素样式。

正确的写法是给最后一个small的::after伪元素设置样式:

.note-right small::after { 
  content: "\a\a";
  white-space: pre;
}

.note-right small:last-child::after { 
  content: none;
}

这样就能取消最后一个.note-right small元素的末尾双换行了。

内容的提问来源于stack exchange,提问作者rocco

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.21 09:24:21