Skip to content

Instantly share code, notes, and snippets.

@lucadegasperi
Created August 19, 2012 22:49
Show Gist options
  • Save lucadegasperi/3398306 to your computer and use it in GitHub Desktop.
Save lucadegasperi/3398306 to your computer and use it in GitHub Desktop.
Context Based CSS Examples
.titlebar
{
/* titlebar css rules go here */
}
.titlebar .button
{
/* button's titlebar context modified rules go here */
}
.button
{
/* button css rules go here */
}
.titlebar .button
{
/* button's titlebar context modified rules go here */
}
.button
{
/* default css rules go here */
}
.titlebar .button
{
/* titlebar context rules go here */
background: red;
}
.sidebar .button
{
/* titlebar context rules go here */
background: red;
}
.modal-box .button
{
/* titlebar context rules go here */
background: red;
}
.button
{
/* default css rules go here */
}
.titlebar .button
{
/* titlebar context rules go here */
}
<div class="titlebar">
<a class="button" href="#">I'm a different button</a>
</a>
<a class="button" href="#">I'm the default button</a>
.button
{
/* default css rules go here */
}
.button.different
{
/* different css rules go here */
}
<div class="titlebar">
<a class="button different" href="#">I'm a different button</a>
</a>
<a class="button" href="#">I'm the default button</a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment