偽類對元素進行分類是基於特徵(characteristics)而不是它們的名字、屬性或者內容;原則上特徵是不可以從文檔樹上推斷得到的。
基本介紹
- 中文名:偽類
- 類型:CSS術語
- 相關概念:偽類
- 領域:計算機
CSS術語
釋義
示例
圖1 效果圖<!DOCTYPE HTML><html> <head> <meta charset="utf-8"> <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> <style type="text/css"> p{ text-align:center; } p:after, p:before{ content:""; position:absolute; height:2px; width:200px; } p:after{ right:0; background-color:red; } p:before{ left:0; background-color:green; } </style> <title>test</title> </head> <body> <p> 測試 </p> </body></html>
圖2 示意圖