Created
November 2, 2016 16:04
-
-
Save Camwyn/6e659c60c5d3410c98edc792f12a01c2 to your computer and use it in GitHub Desktop.
CSS Line Clamp
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
/** | |
* CSS Line Clamp | |
* | |
* @example scss | |
* @include line-clamp(2, 16, 1.5) | |
* | |
* @param {Integer} $lines: number of lines to show | |
* @param {Integer} $font-size: font size in px (no trailing 'px'!) | |
* @param {Integer} $line-height: line height (multiplier/unitless) | |
*/ | |
@mixin line-clamp($lines, $font-size, $line-height) { | |
-webkit-box-orient: vertical; | |
-webkit-line-clamp: $lines; | |
display: -webkit-box; | |
height: #{$lines * ( $font-size / 16 ) * $line-height}em; | |
padding: 0; | |
text-overflow: ellipsis; | |
text-overflow: -o-ellipsis-lastline; // old Opera | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment