html - :nth-child() not working

标签 html css css-selectors

我正在尝试使用 :nth-child(5); 拉伸(stretch)背景上的图像以进行第三次打印。但它没有捕获它。我做错了什么吗?

table#OppPracticeOverview tr th {
    padding:5px !important;
    background-color:transparent;
}
table#OppPracticeOverview tr th img {
    width:47px;
    height:22px;
    float:left;
    margin:-5px 0 0 -42px;
    position:absolute;
    z-index:-1;
}
table#OppPracticeOverview tr th img:nth-child(5) {
    width:110px;
    height:22px;
    float:left;
    margin:-5px 0 0 -105px;
    position:absolute;
    z-index:-1;
}

HTML:

<table id="OppPracticeOverview">
<tbody>
    <tr>
        <th>
            Patients
            <img src="/images/img-CCCCCC.png">
       </th>
       <td>
       <th>
           On Hold
           <img src="/images/img-CCCCCC.png">
        </th>
        <td>
        <th>
           Reattribution Request
          <img src="/images/img-CCCCCC.png">
       </th>
       <td>
   </tr>
</tbody>

最佳答案

你几乎是对的,只需将 nth-childimg 移动到 th 即可,如下所示:table#OppPracticeOverview tr th :nth-child(5) img

演示:http://jsfiddle.net/G79X9/1/

关于html - :nth-child() not working,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15881468/

相关文章:

javascript - 如何隐藏选择选项的旧样式版本?

html - 使用 CSS 圆 Angular 将页眉扩展到页面顶部

css - 第一行上方的第二行文本

javascript - 在 textarea 中输入实际上并没有改变 HTML 标签内容

CSS动画,是否可以在多个元素之间循环?

html - 除了主要元素 div 之外,如何在没有额外 div 的情况下停止 box-shadow 与元素一起旋转?

javascript - Polymer 1.0 全局变量

javascript - 更改 javascript 以在彼此之上淡入而不是淡入/淡出?

html - 最后一个 child 似乎没有工作

javascript - 不包含 block 引用的节点的查询选择器