Skip to content

Instantly share code, notes, and snippets.

@aaronsummers
Created March 14, 2018 12:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaronsummers/a295b141fcb3b7091846b9d0b33f8fff to your computer and use it in GitHub Desktop.
Save aaronsummers/a295b141fcb3b7091846b9d0b33f8fff to your computer and use it in GitHub Desktop.
SCSS Simple mixin
%title-style {
&:after {
content: '';
position: absolute;
bottom: 0;
width: px(58);
height: px(4);
}
position: relative;
padding-bottom: 1rem;
}
@mixin title-border($color) {
@extend %title-style;
&:after {
background: $color;
}
}
@aaronsummers
Copy link
Author

aaronsummers commented Mar 14, 2018

Simple example of a mixin,
I have a project with mulitiple title colours, some require a matching border and some don't.

So to add the border to the required title add:

.introduction h1 {
    @include title-border($text_blue);
}

I've seperated the static part of the mixin into an extend property. As this will only be included once in the stylesheet, it'll help with the weight of the css.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment