Skip to content

Instantly share code, notes, and snippets.

@elgervb
Created September 6, 2016 11:58
Show Gist options
  • Save elgervb/c6e74ad0d1da58cd66146635ede78b28 to your computer and use it in GitHub Desktop.
Save elgervb/c6e74ad0d1da58cd66146635ede78b28 to your computer and use it in GitHub Desktop.
/**
* 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