我想以这种方式选择带有 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>
不幸的是,这不适用于那些元素。 *.x *
都没有。
我做错了什么?
最佳答案
你不能有 <p>
在<p>
.尝试改变你的内心 <p>
标记为 <span>
标签。
希望对你有帮助
关于css 选择具有类的元素的所有后代(星号),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2282522/