CSS 后代选择器

cssweb developmentfront end technology更新于 2024/4/24 12:28:17

CSS 中的后代选择器用于匹配指定元素的所有后代元素。

示例

您可以尝试运行以下代码来实现 CSS 后代选择器:

<!DOCTYPE html>
<html>
   <head>
      <style>
         div p {
            background-color: orange;
         }
      </style>
   </head>
   <body>
      <div>
         <p>Para 1 in the div</p>
         <p>Para 2 in the div</p>
      </div>
      <p>Para 3 outside the div.</p>
   </body>
</html>

输出


相关文章


有用资源