Skip to content

Instantly share code, notes, and snippets.

@erkarp
Last active January 30, 2018 22:05
Show Gist options
  • Save erkarp/d42b5520ccb87c7a1b51d37427282f6f to your computer and use it in GitHub Desktop.
Save erkarp/d42b5520ccb87c7a1b51d37427282f6f to your computer and use it in GitHub Desktop.
Sass mixin to 'crop' an image with CSS clip-path
@mixin resizeImageY($x) {
width: 100%;
clip-path: inset(0 0 $x 0);
-webkit-clip-path: inset(0 0 $x 0);
margin-bottom: -$x;
}
@mixin resizeImageX($x) {
$half: $x/2;
clip-path: inset(0 $half+px 0 0);
-webkit-clip-path: inset(0 $half+px 0 $half+px);
margin-right: -$half+15+px;
margin-left: -$half+px;
}
.panel img {
@include resizeImageY(55px);
@include resizeImageX(100);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment