Skip to content

Instantly share code, notes, and snippets.

@victorpavlov
Last active October 2, 2019 12:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save victorpavlov/e56d8f790ced0e563ec0322a4da2ac17 to your computer and use it in GitHub Desktop.
Save victorpavlov/e56d8f790ced0e563ec0322a4da2ac17 to your computer and use it in GitHub Desktop.
// e.g: @include truncate(14px, 1.4, 10)
@mixin truncate($font-size: 16px, $line-height: 1.5, $lines-to-show: 3) {
display: block; // Fallback for non-webkit
display: -webkit-box;
max-width: 100%;
max-height: $font-size*$line-height*$lines-to-show; // Fallback for non-webkit
line-height: $line-height;
-webkit-line-clamp: $lines-to-show;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment