css选择带有类的元素的所有后代(星号)

myk*_*hal 3 css selector

我想用这种方式用class ="x"选择元素的所有后代元素:

<!DOCTYPE html>
<html>
<head>
  <style type="text/css">
    .x * {
      color: red;
    }
  </style>
</head>
<body>
  a
  <p>
    b
     <p class="x">
        c
        <p> should be red </p> foo
     </p>
  </p>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

遗憾的是,这些元素并不适用.也*.x *没有.

我究竟做错了什么?

mat*_*sta 5

你不能拥有<p>一个<p>.尝试将内部<p>标记更改为<span>标记.

希望这可以帮助