定义和用法
:before 选择器在被选元素的内容前面插入内容。
请使用 content 属性来指定要插入的内容。
实例:
<!DOCTYPE html> <html> <head> <style> p:before { content:"台词:"; background-color:yellow; color:red; font-weight:bold; } </style> </head> <body> <p>我是唐老鸭。</p> <p>我住在 Duckburg。</p> </body> </html>
运行结果: