Last active
June 18, 2022 10:00
-
-
Save drementer/131d8df5109952f1905f3bad3a8a552a to your computer and use it in GitHub Desktop.
Scss Text Truncate Mixin
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
/// Truncate | |
/// Sets the maximum number of rows the element will have | |
/// If the maximum line is exceeded, cut off the excess lines. | |
/// puts "..." at the end of the last line | |
/// @param {number} $max-line [2] - max line of paragraph | |
/// @example scss - truncate mixin | |
/// .text { | |
/// @include truncate(2); | |
/// } | |
@mixin truncate($max-line: 2) { | |
display: -webkit-box; | |
-webkit-line-clamp: $max-line; | |
-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
Also, if the text you cut has a padding value, replace it with a margin or remove it.