Last active
August 19, 2021 08:27
-
-
Save kaelig/7528069 to your computer and use it in GitHub Desktop.
This file contains 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
// Clamps a block of text to a certain number of lines, | |
// followed by an ellipsis in Webkit and Blink based browsers | |
// Reference: http://dropshado.ws/post/1015351370/webkit-line-clamp | |
@mixin text-clamp($lines: 2, $line-height: false) { | |
overflow: hidden; | |
display: -webkit-box; | |
-webkit-box-orient: vertical; | |
-webkit-line-clamp: $lines; | |
// Fallback for non-Webkit browsers | |
// (won't show `…` at the end of the block) | |
@if $line-height { | |
max-height: $line-height * $lines * 1px; | |
} | |
} |
to keep the ellipsis:
text-overflow: ellipsis;
is there any properties for min 2 lines? (even if the text take space only for one line - the second was invisible)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is perfect, love the fallback 👍