CSS: How to say .class:last-of-type [classes, not elements!]

Sliq picture Sliq · Nov 3, 2012 · Viewed 88.8k times · Source

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 ?

Answer

amustill picture amustill · Nov 3, 2012

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.