Skip to content

Instantly share code, notes, and snippets.

@CheetoMao
Created October 3, 2014 16:46
Show Gist options
  • Save CheetoMao/97fe32fed2bce37bb0ff to your computer and use it in GitHub Desktop.
Save CheetoMao/97fe32fed2bce37bb0ff to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
<p>Here is a button, it has a box-shadow that shows up well on lighter colors but it doesn't show up well on darker colors. This is where we can use the reverse nested selector to make a tiny change, darkening the box-shadow, when it's contained in a darker colored container.</p>
<div class="lite">
<button class="button-primary">I'm a button</button>
</div>
<div class="dark">
<button class="button-primary">I'm the same kind of button</button>
</div>
// ----
// Sass (v3.4.4)
// Compass (v1.0.1)
// ----
p {
color: #666;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
line-height: 1.6;
padding: 1rem 2rem;
}
.lite {
background: #EEE;
}
.dark {
background: #555;
}
.button-primary {
background: #FAFAFA;
border: none;
border-radius: 4px;
color: #8e44ad;
cursor: pointer;
font-size: 1.25rem;
margin: 2rem;
padding: 1rem 2rem;
box-shadow: 0 4px 3px 0 rgba(0,0,0,.2);
.dark & {
box-shadow: 0 4px 3px 0 rgba(0,0,0,.45);
}
}
p {
color: #666;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
line-height: 1.6;
padding: 1rem 2rem;
}
.lite {
background: #EEE;
}
.dark {
background: #555;
}
.button-primary {
background: #FAFAFA;
border: none;
border-radius: 4px;
color: #8e44ad;
cursor: pointer;
font-size: 1.25rem;
margin: 2rem;
padding: 1rem 2rem;
box-shadow: 0 4px 3px 0 rgba(0, 0, 0, 0.2);
}
.dark .button-primary {
box-shadow: 0 4px 3px 0 rgba(0, 0, 0, 0.45);
}
<p>Here is a button, it has a box-shadow that shows up well on lighter colors but it doesn't show up well on darker colors. This is where we can use the reverse nested selector to make a tiny change, darkening the box-shadow, when it's contained in a darker colored container.</p>
<div class="lite">
<button class="button-primary">I'm a button</button>
</div>
<div class="dark">
<button class="button-primary">I'm the same kind of button</button>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment