每个<p>元素之后插入内容:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>菜鸟教程(cainiaojc.com)</title>
<style>
p:after
{
content:"- 标记我";
}
</style>
</head>
<body>
<p>我的名字是 丽丽</p>
<p>我住在 海边</p>
<p><b>注意:</b> :after在IE8中运行,必须声明 !DOCTYPE </p>
</body>
</html>
测试看看 ‹/›:after 选择器向选定的元素之后插入内容。
使用content 属性来指定要插入的内容。
表格中的数字表示支持该属性的第一个浏览器版本号。
选择器 | |||||
---|---|---|---|---|---|
::after | 4.0 | 9.0 部分从 8.0 | 3.5 | 3.1 | 7.0 部分从4.0 |
注意: after在IE8中运行,必须声明<!DOCTYPE> .
CSS 教程: CSS Pseudo-elements
CSS 选择器参考手册: CSS :before 选择器
在每个 <p>之后插入的内容和样式:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>菜鸟教程(cainiaojc.com)</title>
<style>
p:after
{
content:"- 标记";
background-color:yellow;
color:red;
font-weight:bold;
}
</style>
</head>
<body>
<p>我的名字是 丽丽</p>
<p>我住在 海边</p>
<p><b>注意:</b> :after在IE8中运行,必须声明 !DOCTYPE </p>
</body>
</html>
测试看看 ‹/›