CSS 之伪类对象选择符(Pseudo-element)

一、选择符

Selectors
选择符
Description
简介
E:first-letter/E::first-letter 设置对象内的第一个字符的样式。
E:first-line/E::first-line 设置对象内的第一行的样式。
E:before/E::before 设置在对象前(依据对象树的逻辑结构)发生的内容。用来和content属性一起使用
E:after/E::after 设置在对象后(依据对象树的逻辑结构)发生的内容。用来和content属性一起使用
E::selection 设置对象被选择时的颜色。

二、示例

<style>
p{position:relative;color:#f00;font-size:14px;font-size:0\9;*font-size:14px;}
p:before{position:absolute;background:#fff;color:#000;content:"如果你的能看到这段文字,说明你的浏览器只支持E:before";font-size:14px;}
p::before{position:absolute;background:#fff;color:#000;content:"如果你的能看到这段文字,说明你的浏览器支持E:before和E::before";font-size:14px;}
</style>
</head>
<body>
<p>Sorry, 你的浏览器不支持E:before和E::before</p>
</body>
posted @ 2019-12-14 09:34  样子2018  阅读(245)  评论(0)    收藏  举报