使用 CSS 选择 div 元素内的所有元素

cssweb developmentfront end technology更新于 2024/7/24 10:20:17

使用 element element选择器选择另一个元素内的所有元素。

您可以尝试运行以下代码来实现element element选择器,

示例

<!DOCTYPE html>
<html>
   <head>
      <style>
         div p {
            color: white;
            background-color: blue;
         }
      </style>
   </head>
   <body>
      <h1>Demo Website</h1>
      <h2>Fruits</h2>
      <p>Fruits are good for health.</p>
      <div>
         <p>This is demo text.</p>
      </div>
   </body>
</html>

相关文章


有用资源