Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

CSS Sass Basics Improve Your Workflow with Sass Write Nested Selectors

Kayla Pasciullo
seal-mask
.a{fill-rule:evenodd;}techdegree
Kayla Pasciullo
Front End Web Development Techdegree Student 7,521 Points

creating a nested selector in SASS with ampersand

Ive been stuck on this question googling for an answer with no success for an hour :(

heres the question: use the & to create a nested selector .icn-success and give it the color green

ive tried

.icn { font:size: 1.25em &.icn-success { color:green; } }

also tried & icn-success &-icn.success &--icn.sucess .icn-success &

please help !!! TIA

style.scss
.banner {
  padding: 1em;
  background-color: lightgrey;
 .button {
font-size: 1.5em;
}
}

.icn {
font-size: 1.25em;
&.icn-success {
color: green;
}
}
Blake Larson
Blake Larson
12,932 Points

You want to just continue to concat starting with the parent class.

&-success

In this example the & = .icn

To add additional examples of this using BEM

<div class="block">
  <span class="block__element"></span>
  <span class="block__element block__element--modifier"></span>
</div>
.block {
 position: relative;

 &__element {
   position: absolute;
   top: 0;
   left: 0;

   &--modifier {
     left: 50px;
   }
 }
}