导航
×
   ❮   
HTML CSS JavaScript PHP Go Sass W3C Colors ECMS

CSS ::after 伪元素


实例

在每个<p> 元素的内容之后插入一个字符串

p::after {
  content: " - Remember this";
}
亲自试一试 »

更多“自己尝试”的例子见下文。


定义和用法

::after 伪元素在指定元素的**内容之后**插入一些内容。

使用 content 属性指定要插入的内容。 content 的值可以是:

  • 字符串: content: "你好,世界!";
  • 图片: content: url(myimage.jpg);
  • 无: content: none;
  • 计数器: content: counter(li);
  • 引号: content: close-quote;
  • 属性值: content: " (" attr(href) ")";

提示: 请注意,插入的内容仍然在指定元素的**内部**。插入的内容是在其他内容之后添加的。

使用 ::before 在指定元素的**内容之前**插入一些内容。

版本 CSS2

浏览器支持

表中数字表示首次完全支持此伪元素的浏览器版本。

伪元素
::after 4.0 9.0 3.5 3.1 7.0

CSS 语法

::after {
  CSS 声明;
}

更多实例

实例

在每个<p> 元素的**内容之后**插入一个字符串,并对插入的内容进行样式设置

p::after {
  content: " - Remember this";
  background-color: yellow;
  color: red;
  font-weight: bold;
}
亲自试一试 »

相关页面

CSS 教程:CSS 伪元素

CSS 伪元素参考: ::before


Copyright ©2020-2026 freew3c.com All Rights Reserved 提供的内容仅用于学习和测试,不保证内容的正确性。