Last active
January 30, 2018 22:05
-
-
Save erkarp/d42b5520ccb87c7a1b51d37427282f6f to your computer and use it in GitHub Desktop.
Sass mixin to 'crop' an image with CSS clip-path
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @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