Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS Compass Basics Compass Helper Functions Color Helpers

Manu Santana
Manu Santana
8,329 Points

Color Helpers... How can apply the linear-gradient to the rest of li:nth-child with a mixing or similar?

I'd like apply the gradient to the rest of nth-child and I don't know if it's possible.

In this example.

.colors { li { background-color: $base; } li:nth-child(2) { background: adjust-lightness($base, 10%); } li:nth-child(3) { background: adjust-saturation($base, 30%); } li:nth-child(4) { @include background ( linear-gradient($base, shade($base, 50%))); } li:nth-child(5) { background: tint($base, 40%);
}

Thank you in advance

So heres a couple ways. You can select every other child by specifying odd or even within the perenthesis.

li:nth-child(odd) { }
li.nth-child(even) { }

You can also choose every third, sixth or tenth child by using expressions. This one selects every third.

li:nth-child(n3+3) { }

hope this helps.

1 Answer

Manu Santana
Manu Santana
8,329 Points

Dear Nick,

Thank for your answer. But I'm referring to create a mixin or similar to write the code the simplest way. Thanks again.