Skip to content

Instantly share code, notes, and snippets.

@Undistraction
Last active August 29, 2015 14:08
Show Gist options
  • Save Undistraction/2dbd8de91d02fe340c0a to your computer and use it in GitHub Desktop.
Save Undistraction/2dbd8de91d02fe340c0a to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
<div class="Box--right"></div>
<div class="Box--bottom"></div>
<div class="Box--left"></div>
<div class="Box--top"></div>
// ----
// Sass (v3.4.6)
// Compass (v1.0.1)
// ----
// Lib
//------------------------------------------------
@mixin triangle( $length, $direction, $colour ) {
$adjacent: opposite-side($direction);
border: $length solid transparent;
border-#{$adjacent}: $length solid $colour;
border-#{$direction}: 0;
height:0;
width:0;
}
@function opposite-side($side){
$sides:(
top: bottom,
bottom: top,
left: right,
right: left
);
@return map-get($sides, $side);
}
// Use
//------------------------------------------------
.Box--right {
@include triangle(20px, right, red)
}
.Box--left {
@include triangle(20px, left, red)
}
.Box--top {
@include triangle(20px, top, red)
}
.Box--bottom {
@include triangle(20px, bottom, red)
}
.Box--right {
border: 20px solid transparent;
border-left: 20px solid red;
border-right: 0;
height: 0;
width: 0;
}
.Box--left {
border: 20px solid transparent;
border-right: 20px solid red;
border-left: 0;
height: 0;
width: 0;
}
.Box--top {
border: 20px solid transparent;
border-bottom: 20px solid red;
border-top: 0;
height: 0;
width: 0;
}
.Box--bottom {
border: 20px solid transparent;
border-top: 20px solid red;
border-bottom: 0;
height: 0;
width: 0;
}
<div class="Box--right"></div>
<div class="Box--bottom"></div>
<div class="Box--left"></div>
<div class="Box--top"></div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment