css中before的用法是什么
时间:2022-02-11 16:41
在css中,before的用法是在元素内容之前插入新内容,只需要给元素设置“元素:before{属性:属性值;}”即可。“:before”选择器必须使用content属性来指定要插入的内容。 本教程操作环境:windows7系统、CSS3&&HTML5版、Dell G3电脑。 定义和用法 :before 选择器在被选元素的内容前面插入内容。 请使用 content 属性来指定要插入的内容。 实例: 运行结果: 推荐学习:css视频教程 以上就是css中before的用法是什么的详细内容,更多请关注gxlsystem.com其它相关文章!<!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>