Skip to content

Instantly share code, notes, and snippets.

@lilithebowman
Created September 7, 2018 19:09
Show Gist options
  • Save lilithebowman/a38df5b848814107c8a27cc27c3d6fc0 to your computer and use it in GitHub Desktop.
Save lilithebowman/a38df5b848814107c8a27cc27c3d6fc0 to your computer and use it in GitHub Desktop.
// Truncates text to a specified number of lines using height,
// Note: Only works in webkit browsers.
@mixin truncateLines($lineNum: 3, $lineHeight: 1.3, $fontSize: em(18)) {
$totalHeight: $lineNum * $lineHeight;
-webkit-box-orient: vertical;
-webkit-line-clamp: $lineNum;
display: -webkit-box;
display: block;
font-size: $fontSize;
height: auto;
line-height: $lineHeight;
max-height: ($fontSize*$lineHeight*$lineNum);
overflow: hidden;
text-overflow: ellipsis;
word-wrap: break-word;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment