dd

CSS :before 选择器


实例

每个 <p>元素之前插入内容:

p:before
{
content:"Read this: ";
}
运行一下 »

定义和说明

:before 选择器向选定的元素前插入内容。

使用content 属性来指定要插入的内容。

浏览器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

所有主流浏览器都支持:before选择器。

注意: before在IE8中运行,必须声明 <!DOCTYPE>

在线实例

实例

在每个<p>之前插入的内容和样式:

p:before
{
content:"Read this -";
background-color:yellow;
color:red;
font-weight:bold;
}
运行一下 »