I want to select the penultimate element with CSS. The code looks this way:
so I tried this:
.panel-default > [id^=heading]:last-of-type {
border-bottom: 5px solid blue;
}
But with no luck. Any idea how to always select the last "panel-heading" element?
The :last selector selects the last element. Note: This selector can only select one single element. Use the :last-child selector to select more than one element (one for each parent). This is mostly used together with another selector to select the last element in a group (like in the example above).
To select the last element of a specific class, you can use the CSS :last-of-type pseudo-class.
The :last-of-type selector allows you to target the last occurence of an element within its container. It is defined in the CSS Selectors Level 3 spec as a “structural pseudo-class”, meaning it is used to style content based on its relationship with parent and sibling content. ).
try
.panel-default > *:nth-last-of-type(2) {
border-bottom: 5px solid blue;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With