Skip to content

Instantly share code, notes, and snippets.

@mootari
Created October 9, 2014 18:18
Show Gist options
  • Save mootari/1c95efe8cbcae6d9b4cc to your computer and use it in GitHub Desktop.
Save mootari/1c95efe8cbcae6d9b4cc to your computer and use it in GitHub Desktop.
followed-by: Apply content to adjacent siblings. #sassmeister #mixin
// ----
// Sass (v3.4.4)
// Compass (v1.0.1)
// ----
@mixin followed-by($selectors...) {
$placeholder: "%#{unique_id()}";
@at-root #{$placeholder} {
@content;
}
@each $selector in $selectors {
+ #{$selector} {
@extend #{$placeholder};
}
}
}
.formatted p {
@include followed-by(ul, ol) {
margin-top: 10px;
}
}
.formatted p + ul, .formatted p + ol {
margin-top: 10px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment