您好,欢迎访问一九零五行业门户网

css中before的用法是什么

在css中,before的用法是在元素内容之前插入新内容,只需要给元素设置“元素:before{属性:属性值;}”即可。“:before”选择器必须使用content属性来指定要插入的内容。
本教程操作环境:windows7系统、css3&&html5版、dell g3电脑。
定义和用法
: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>
运行结果:
推荐学习:css视频教程
以上就是css中before的用法是什么的详细内容。
其它类似信息

推荐信息