CSS :before 选择器
定义和说明
:before 选择器向选定的元素前插入内容。
使用content 属性来指定要插入的内容。
浏览器支持
表格中的数字表示支持该属性的第一个浏览器版本号。
选择器 | |||||
---|---|---|---|---|---|
::before | 4.0 | 9.0 部分从8.0 |
3.5 | 3.1 | 7.0 部分从 4.0 |
注意: before在IE8中运行,必须声明 <!DOCTYPE> 。
相关文章
CSS 教程: CSS Pseudo-elements
CSS 选择器参考手册: CSS :after 选择器

更多实例
实例
在每个<p>之前插入的内容和样式:
p:before
{
content:"Read this -";
background-color:yellow;
color:red;
font-weight:bold;
}
{
content:"Read this -";
background-color:yellow;
color:red;
font-weight:bold;
}
尝试一下 »
