user2565968
user2565968

Reputation:

How do I delete the background of my last DIV element?

How do I delete the background of my last DIV using class="item"?

Parent is: <div id="lastQuestions"></div>

jsfiddle

Upvotes: 0

Views: 103

Answers (2)

Martin Turjak
Martin Turjak

Reputation: 21214

Alternatively, you could use a different html tag (like span, p or li displayed as block) for the.item elements instead of div to differentiate them from other div elements, and then you can do something like:

#lastQuestions li:last-of-type {
    background: none;
}

to select it.

quick illustration

Edit:

Since, according to your jsfiddle, only .item elements are of type div in your code they already differ in type from all other children of #lastQuestions. So you can just try this:

#lastQuestions > div:last-of-type {
    background: none;
}

DEMO

Upvotes: 0

user2568107
user2568107

Reputation:

.item:last-child {
    background-color: inherit;
}

Use pseudo element last-child

Here is a working jsfiddle

Upvotes: 4

Related Questions