css selector to select a table cell contains img
This question already has an answer here:
In CSS4 there is a spec, to mark the element, which you want to style, in a larger selector. The actual symbol varies and currently points to !
.
So in your case the selector would look like this (according to the current spec):
table !td img {
font-color: red;
}
Note, however, that this is not supported in any current browser.
Do you know ahead of time which cells will have an image in them? If so add a class to the td element, for example:
<tr>
<td class="has-image"><img src="..." /></td>
</tr>
That's the easiest way... Otherwise you'd need to use JavaScript. In jquery this would look like:
$('td img').parents('td').addClass('has-image');
链接地址: http://www.djcxy.com/p/22838.html
上一篇: 允许用于CSS标识符的字符