0

I need to select the last-child element who class begins with a specific value. Let's suppose I have the next html structure elements:

<div class="wrapper">
  <div class="test-1">this is test-1</div>
  <div class="test-2">this is test-2</div>
  <div class="test-3">this is test-3</div>
  <div class="test-4">this is test-4</div>
  <div class="another-test">this is the another test</div>
</div>

So, I want to select the div with class="test-4". I'm using the next SCSS code but it doesn't work.

div.wrapper div[class^="test"]:last-child {
  background-color: red;
}
cimmanon
  • 67,211
  • 17
  • 165
  • 171
carma03
  • 21
  • 2
  • I think you are looking for the :last selector and not the :last-child selector – karina Apr 17 '16 at 22:59
  • Sorry, but there's currently no kind of "parameterized" `last-of-type` selector. – 4castle Apr 17 '16 at 23:07
  • An even closer duplicate for this question is [CSS last-child selector: select last-element of specific class, not last child inside of parent?](http://stackoverflow.com/q/7298057/5743988) – 4castle Apr 17 '16 at 23:12
  • You might be able to get your desired result though with `:nth-last-child(2)` – 4castle Apr 17 '16 at 23:19

0 Answers0