Created
September 6, 2016 11:58
-
-
Save elgervb/c6e74ad0d1da58cd66146635ede78b28 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
/** | |
* Truncate the current element with a ellipsis over a fixed number of lines when it does not fit | |
* | |
* @param {strimg} $lineHeight The line height with unit (1em, 1.785rem, 25px) | |
* @param {number} $lineCount The number of lines to show | |
* @param { | |
* | |
* @see http://hackingui.com/front-end/a-pure-css-solution-for-multiline-text-truncation/ | |
*/ | |
@mixin wrap-ellipsis-multiline($lineHeight: 1.2em, $lineCount: 1, $bgColor: #ffffff){ | |
margin-right: -1em; | |
max-height: $lineHeight * $lineCount; | |
overflow: hidden; | |
padding-right: 1em; | |
position: relative; | |
text-align: justify; | |
&:before { | |
content: '…'; | |
position: absolute; | |
right: .25em; | |
bottom: 0; | |
} | |
&:after { | |
content: ''; | |
position: absolute; | |
right: 0; | |
width: 1em; | |
height: 1em; | |
margin-top: 0.2em; | |
background: $bgColor; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment