:first-child
matches the first child of its parent. Your first a.trigger
is not the first child — that would be the classless a
before it.
:first-of-type
and :nth-of-type(1)
, which are equivalent, match the first element of its type within its parent. In this case, your classless a
is also the first a
of its parent, making your first a.trigger
the second a
element.
Is your given structure how your dynamic element will always be generated? If so, you can simply select a.trigger:nth-child(2)
instead of a.trigger:first-child
:
.ui-collapsible-tabs.ui-dynamic-tabs .ui-collapsible-heading a.trigger:nth-child(2) {
right: 0;
background-color: red !important;
border-right: 1px solid red;
}
Or you can try a + a.trigger
:
.ui-collapsible-tabs.ui-dynamic-tabs .ui-collapsible-heading a + a.trigger {
right: 0;
background-color: red !important;
border-right: 1px solid red;
}
(That !important
probably isn't needed by the way.)
Otherwise if you need to select the first a.trigger
in general you will need to order your declarations differently and change up your selectors a bit:
.ui-collapsible-tabs.ui-dynamic-tabs .ui-collapsible-heading a.trigger {
background: none repeat scroll 0 0 transparent;
background-color: red !important;
border: 0 none;
border-right: 1px solid red;
border-radius: 0;
box-shadow: none;
position: absolute;
right: 0;
height: 100%;
top: 0;
width: 2em;
}
.ui-collapsible-tabs.ui-dynamic-tabs .ui-collapsible-heading a.trigger + a.trigger {
right: 2em;
background-color: transparent;
border-right: 0 none;
}
If your two a.trigger
s aren't always adjacent, replace +
with ~
.
The generic solution is covered in detail here.