将样式应用于标记中的子元素

时间:2017-07-26 14:23:24

标签: jquery html css

想要在标记中设置第一个元素的样式。我想在我的标签中为第一个元素添加一个光标指针效果。

这是我的代码

<div class="cut-image-yellow">
<td class="col-md-1 " style="vertical-align: inherit;">
<span class="number-10 text-center" id="number-10-<?php echo $row['id_vnr']; ?>"><?php echo $row['cut10_vnr']; ?></span>
<img alt="" class="yellow-process-cut   process-<?php echo $row['id_vnrp']; ?>"  src="../../css/icons/vinyl-rolls/cut.png">

</td>
</div>

我想对标签内的标签产生影响。

我尝试了这个,但我没有工作。

<style>
        .cut-image-yellow>td>img:nth-child(1) {
        cursor: pointer;
    }
    </style>

如何定位课程内部“cut-image-yellow&gt; td&gt; img 和cursor:pointer效果。

非常感谢提前。

1 个答案:

答案 0 :(得分:0)

我认为问题是td代码中包含div标记,因为这样做

.cut-image-yellow img:nth-of-type(1) {
        cursor: pointer;
    }

但是

.cut-image-yellow td img:nth-of-type(1) {
        cursor: pointer;
    }

另外,如果您将td标记更改为另一个div,那么这也可以使用

.cut-image-yellow div img:nth-of-type(1) {
        cursor: pointer;
    }