Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select penultimate element

Tags:

css

I want to select the penultimate element with CSS. The code looks this way:

enter image description here

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?

like image 724
Henning Fischer Avatar asked Jul 14 '16 09:07

Henning Fischer


People also ask

How do you choose the last 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).

How do I select the last div element on the page?

To select the last element of a specific class, you can use the CSS :last-of-type pseudo-class.

How do you select the last element in CSS?

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. ).


1 Answers

try

.panel-default > *:nth-last-of-type(2) {
    border-bottom: 5px solid blue;

}

like image 128
Mark Perera Avatar answered Jan 03 '23 23:01

Mark Perera