您的位置:首页 > Web前端 > CSS

css匹配选择第n个子元素

2014-03-02 17:57 253 查看
加入要让第二个 th 占table表格总宽度的50%.

<style type = "text/css">

table tr th:nth-child(2)

</style>

<table>

<tr>

<th>第一个</th>

<th>第二个</th>

<th>第三个</th>

</tr>

</table>

定义:

:nth-child(n) 选择器匹配属于其父元素(在这里就是tr)的第
N (这里选择第2个)个子元素(这里子元素是th),不论元素的类型。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐