Skip to content

Instantly share code, notes, and snippets.

@justinmc
Last active February 2, 2019 21:14
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save justinmc/9837998 to your computer and use it in GitHub Desktop.
Save justinmc/9837998 to your computer and use it in GitHub Desktop.
SASS Zigzag Border
/* border-serrated - a zig zag triangle border with linear gradient
*/
@mixin border-top-serrated($size, $color-outer) {
& {
position: relative;
overflow: auto;
padding-top: $size;
}
&:before {
top: 0px;
background-position: left top;
@include background(linear-gradient(-135deg, $color-outer $size / 2, transparent 0), linear-gradient(135deg, $color-outer $size / 2, transparent 0));
@include border-serrated-helper($size, $color-outer);
}
}
@mixin border-bottom-serrated($size, $color-outer) {
& {
position: relative;
overflow: auto;
padding-bottom: $size;
}
&:after {
bottom: 0px;
background-position: left bottom;
@include background(linear-gradient(-45deg, $color-outer $size / 2, transparent 0), linear-gradient(45deg, $color-outer $size / 2, transparent 0));
@include border-serrated-helper($size, $color-outer);
}
}
@mixin border-serrated-helper($size, $color-outer) {
content: " ";
display: block;
position: absolute;
left: 0px;
width: 100%;
height: $size;
background-repeat: repeat-x;
background-size: $size $size;
}
@justindujardin
Copy link

This is great, thanks. I needed a LESS version: https://gist.github.com/justindujardin/10057651

@justinmc
Copy link
Author

@justindujardin Nice LESS version, thanks for linking that.

@gilbarbara
Copy link

I've made a sass/svg mixin for zigzag borders: http://codepen.io/gilbarbara/pen/pvwmEb

@fxck
Copy link

fxck commented Oct 23, 2017

@include background where's this one defined?

@fxck
Copy link

fxck commented Oct 23, 2017

I see, bourbon.

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