CSS:怎么说.class:last-of-type [classes,not elements!] [英] CSS: How to say .class:last-of-type [classes, not elements!]
问题描述
$ b选择最后一个孩子 $ b
正如标题所说,我想将CSS规则添加到某个类型的最后一个元素,该元素具有某个类。以下代码完美地工作:
div:last-of-type {margin-right:0; }
但我想要像
div.class:last-of-type {margin-right:0; }
如何做到这一点?
不幸的是找到最后的 .class
是不可能的最后的类型
。
编辑:
要实际添加一些建设性的东西到这个答案,你可以回到JavaScript找到这个选择器,修改您的标记/ CSS。虽然我发现自己在最后的类型
一个类选择器将是有用的情况下,这是没有什么是不能解决一个更多的想法。 p>
Possible Duplicate:
How do I select the "last child" with a specific class name in CSS?
As the title says, i want to adress css rules to the last element of a certain type which has a certain class. The following code works perfectly:
div:last-of-type { margin-right:0; }
but i want something like
div.class:last-of-type { margin-right:0; }
How to do this ?
Unfortunately finding the last .class
is not possible with last-of-type
.
Edit:
To actually add something constructive to this answer, you could fallback to JavaScript to locate this selector, or revise your markup/CSS. Whilst I have found myself in the situation that last-of-type
for a class selector would be useful, it's nothing that cannot be worked around with a little more thought.
这篇关于CSS:怎么说.class:last-of-type [classes,not elements!]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!