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

Ian Carroll
Ian Carroll
1,901 Points

SCSS Amp Selector

I'm having trouble with this code challenge on SCSS. I'm on my phone, so apologies for any shortcomings.

Here's my code so far.

/* Write your SCSS code below. */

p { a { color: red; }

a { color: blue; :hover & { opacity:0.5; } } }

The challenge reads: We want to add a style to our previous Sass code declaring that on hover, all direct <a> children have an opacity of 0.5. Use the ampersand selector to achieve this, rather than repeating the '> a' direct child selector.

1 Answer

Kevin Korte
Kevin Korte
28,149 Points

Remember, the & is a placeholder for what's nested.

So, your Scss will compile to this in CSS

p a {
  color:red;
  }
p > a {
  color: blue;
  }
:hover p > a {
  opacity: 0.5;
  }

When what you wanted to say was

p > a:hover {
  opacity: 0.5;
  }

So you'll need to adjust where your ampersand is in your Scss.