【发布时间】:2010-10-12 12:55:18
【问题描述】:
我只想将样式应用于具有特定类的 DIV 内的表:
注意:我宁愿为子元素使用 CSS 选择器。
为什么 #1 有效而 #2 无效?
1:
div.test th, div.test td, div.test caption {padding:40px 100px 40px 50px;}
2:
div.test th, td, caption {padding:40px 100px 40px 50px;}
HTML:
<html>
<head>
<style>
div.test > th, td, caption {padding:40px 100px 40px 50px;}
</style>
</head>
<body>
<div>
<table border="2">
<tr><td>some</td></tr>
<tr><td>data</td></tr>
<tr><td>here</td></tr>
</table>
</div>
<div class="test">
<table border="2">
<tr><td>some</td></tr>
<tr><td>data</td></tr>
<tr><td>here</td></tr>
</table>
</div>
</body>
</html>
我做错了什么?
【问题讨论】:
-
别忘了 >、+ 和 [ ] 选择器在 IE6 及以下版本中不可用。
标签: css css-selectors