<div class="block -berry edge--bottom">
  <h1>Bottom Angled Edge</h1>
</div>

<div class="block -blue edge--bottom--reverse">
  <h1>Bottom Angled Edge</h1>
  <p>Reversed</p>
</div>

<div class="block -berry edge--top">
  <h1>Top Angled Edge</h1>
</div>

<div class="block -blue edge--top--reverse">
  <h1>Top Angled Edge</h1>
  <p>Reversed</p>
</div>

<div class="block -orange edge--both">
  <h1>Top & Bottom Angled Edges</h1>
</div>

<div class="block -green edge--both--reverse">
  <h1>Top & Bottom Angled Edges</h1>
  <p>Reversed</p>
</div>
// mixin
@mixin angle($pseudo, $flip: false, $angle: 1.5deg) {
  // Possible values for $pseudo are: before, after, both
  @if $pseudo == 'before' or $pseudo == 'after' or $pseudo == 'both' {
    position: relative;
    z-index: 1;
    $selector: if($pseudo == 'both', '&:before,&:after', '&:#{$pseudo}');

    #{$selector} {
      background: inherit;
      content: '';
      display: block;
      height: 50%;
      left: 0;
      position: absolute;
      right: 0;
      z-index: -1;
      -webkit-backface-visibility: hidden; // for Chrome Windows
    }

    @if $pseudo == 'before' {
      #{$selector} {
        top: 0;

        @if $flip {
          transform: skewY($angle * -1);
          transform-origin: 0 0;
        } @else {
          transform: skewY($angle);
          transform-origin: 100% 0;
        }
      }
    }

    @if $pseudo == 'after' {
      #{$selector} {
        bottom: 0;

        @if $flip {
          transform: skewY($angle);
          transform-origin: 0 100%;
        } @else {
          transform: skewY($angle * -1);
          transform-origin: 100%;
        }
      }
    }

    @if $pseudo == 'both' {
      &:before {
        top: 0;

        @if $flip {
          transform: skewY($angle * -1);
          transform-origin: 0 0;
        } @else {
          transform: skewY($angle);
          transform-origin: 100% 0;
        }
      }

      &:after {
        bottom: 0;

        @if $flip {
          transform: skewY($angle);
          transform-origin: 0 0;
        } @else {
          transform: skewY($angle * -1);
          transform-origin: 100%;
        }
      }
    }
  }
}

// slanted edges here
.edge--bottom {
  @include angle(after);
}

.edge--bottom--reverse {
  @include angle(after, true);
}

.edge--top {
  @include angle(before);
}

.edge--top--reverse {
  @include angle(before, true);
}

.edge--both {
  @include angle(both);
}

.edge--both--reverse {
  @include angle(both, true);
}

.-berry {
  background: #b52b4a;
}

.-blue {
  background: #41ade5
}

.-orange {
  background: #de6628;
}

.-green {
  background: #5e9b42;
}

// demo code below
.block {
  color: #fff;
  font-family: 'Fira Sans', sans-serif;
  margin: 0 0 200px;
  padding: 20% 20px;
  text-align: center;
}

h1 {
  font-size: 32px;
  font-weight: 500;
}

p {
  font-size: 14px;
  font-weight: 300;
  margin-top: 0.5em;
}

External CSS

  1. //fonts.googleapis.com/css?family=Fira+Sans:300,500

External JavaScript

This Pen doesn't use any external JavaScript resources.