Skip to content

Instantly share code, notes, and snippets.

@chris-muller
Last active February 26, 2016 08:46
Show Gist options
  • Save chris-muller/4c6cbe70d8c887afb6dc to your computer and use it in GitHub Desktop.
Save chris-muller/4c6cbe70d8c887afb6dc to your computer and use it in GitHub Desktop.
Heading tags placeholder examples in Sass
// This applies all the rules
// targeting the headings
// placeholder class
h1, h2, h3,
h4, h5, h6 {
@extend %headings !optional;
}
// Example use of headings
// placeholder class
%headings {
color: #2E2E2E;
margin-bottom: 4px;
}
// Unstyles all anchor tags
// inside a heading element
%headings > a {
text-decoration: none;
color: inherit;
&:hover {
text-decoration: underline;
}
}
// Removes top margin of any p tag
// that immediately follows a heading
%headings + p {
margin-top: 0;
}
// Final Generated Output
// ======================
h1, h2, h3,
h4, h5, h6 {
color: #2E2E2E;
margin-bottom: 4px;
}
h1 > a, h2 > a, h3 > a,
h4 > a, h5 > a, h6 > a {
text-decoration: none;
color: inherit;
}
h1 > a:hover, h2 > a:hover, h3 > a:hover,
h4 > a:hover, h5 > a:hover, h6 > a:hover {
text-decoration: underline;
}
h1 + p, h2 + p, h3 + p,
h4 + p, h5 + p, h6 + p {
margin-top: 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment