CSS :before伪元素

描述

:before 伪元素用于在一个元素之前插入一些内容。

示例

下面是一个示例,演示了如何使用 :before 元素在任意元素之前添加一些内容。

<html>
   <head>
      <style type = "text/css">
         p:before {
            content: url(/images/bullet.gif)
         }
      </style>
   </head>

   <body>
      <p> This line will be preceded by a bullet.</p>
      <p> This line will be preceded by a bullet.</p>
      <p> This line will be preceded by a bullet.</p>
   </body>
</html>

这将产生以下的黑色链接-

最后修改:2024 年 05 月 17 日
如果觉得我的文章对你有用,请随意赞赏