哪个元素用于通过 CSS 在元素前插入一些内容

cssweb developmentfront end technology更新于 2025/9/8 19:24:17

使用 :before 元素可在任何元素前插入一些内容。

示例

您可以尝试运行以下代码,使用 CSS 在元素前插入一些内容 −

<html>
   <head>
      <style>
         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>

相关文章


有用资源