Question: I want to make something like `nth-last-child(1 + odd)`, where the last child is affected but **ONLY if the element is odd**.

`nth-last-child(1 + odd)` doesnt work though, so what should I do?

---

**Bonus:** A more flexible answer allowing me to grab the last child, only if it is odd and the odd child before it.

```
<ul>
  <li>not effected</li>
  <li>not effected</li>
  <li>not effected</li>
  <li>not effected</li>
  <li>affected</li>
  <li>not effected</li>
  <li>affected</li>
</ul>

```

but if the last child is EVEN, nothing happens, so:

```
<ul>
  <li>not effected</li>
  <li>not effected</li>
  <li>not effected</li>
  <li>not effected</li>
  <li>not effected</li>
  <li>not effected</li>
</ul>

```

Answer: 
> 
> I want to make something like `nth-last-child(1 + odd)`, where the last child is affected but **ONLY if the element is odd**.
> 
> 
> 

As has already been addressed, `:nth-child(odd):last-child` (or vice versa — order of pseudo-classes doesn't matter).

> 
> **Bonus:** A more flexible answer allowing me to grab the last child, only if it is odd and the odd child before it.
> 
> 
> 

I'm not sure I would consider this more flexible, but selector syntax is pretty limited right now so it's the best you've got:

```
:nth-child(odd):nth-last-child(3),
:nth-child(odd):last-child

```

`:nth-child(odd):nth-last-child(-n+3)` comes pretty close, but that will match the *second last child* if that child is odd-numbered, which is not what you want.

Nothing a little negation couldn't handle if you really must have a single compound selector though:

```
:nth-child(odd):nth-last-child(-n+3):not(:nth-last-child(2))

```
You can combine both selectors like this:

```
:last-child:nth-child(odd)

```

**DEMO**
<http://codepen.io/dschu/pen/XmbKmq>

**SCSS**

```
ul 
{
  li
  {
    &:last-child:nth-child(odd)
    {
      background-color: red;
    }
  }
}

```