为什么这两个不相等?第一个显示绿色行,而第二个没有。唯一的区别在于 html c 此外,nth-child 选择器的特殊性是什么?
<!DOCTYPE html>
<html>
<head>
<title>Stripe Test</title>
<style type='text/css'>
tr:nth-child(2n+1)
{
background-color: red;
}
tr.c
{
background-color: green;
}
</style>
</head>
<body>
<table class='stripe'>
<tr class='c'>
<td>one</td>
</tr>
<tr>
<td>two</td>
</tr>
<tr>
<td>three</td>
</tr>
</table>
</body>
</html>
-对-
<!DOCTYPE html>
<html>
<head>
<title>Stripe Test</title>
<style type='text/css'>
tr:nth-child(2n+1)
{
background-color: red;
}
tr .c
{
background-color: green;
}
</style>
</head>
<body>
<table class='stripe'>
<tr class='c'>
<td>one</td>
</tr>
<tr>
<td>two</td>
</tr>
<tr>
<td>three</td>
</tr>
</table>
</body>
</html>