CSS选择器将样式应用于除第一个图像以外的所有图像 [英] CSS selectors apply style to all images except the first one
问题描述
我以为我可以使用高级CSS选择器来做到这一点,但是很挣扎.
I thought I could do this with advanced CSS selectors, but struggling.
我有一个JS小提琴此处,下面是示例
I have a JS Fiddle here with the below example
基本上,除了第一个图像外,我如何定位此处的每个图像?我不想使用类或ID,如果可能的话,我只想使用高级选择器.
Basically, how can I target every image here, except the first one? I don't want to use classes or IDs, I just want to use advanced selectors, if possible.
所以类似.entry-content img:first-child(尽管我知道那行不通)
So something like .entry-content img:first-child (although I know that wouldn't work)
<div class='entry-content'>
<div>
<img src='http://placedog.com/400/300'/>
</div>
<div>
<img src='http://placedog.com/400/300'/>
</div>
<div>
<img src='http://placedog.com/400/300'/>
</div>
</div>
推荐答案
如果要选择除第一个之外的所有img标签,请使用:not
子类:
If you want to select all img tags except first one use :not
subclass:
.entry-content div:not(:first-child) img
工作示例:
http://jsfiddle.net/GrAaA/
浏览器支持:
:not
http://caniuse.com/#search=%3Anot
:first-child
http://caniuse.com/#search=%3Afirst-child
Working example:
http://jsfiddle.net/GrAaA/
Browser support:
:not
http://caniuse.com/#search=%3Anot
:first-child
http://caniuse.com/#search=%3Afirst-child
这篇关于CSS选择器将样式应用于除第一个图像以外的所有图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!