Skip to content

Instantly share code, notes, and snippets.

@rpbaltazar
Last active August 29, 2015 14:09
Show Gist options
  • Save rpbaltazar/069bc1a1e81ebe9b8eb7 to your computer and use it in GitHub Desktop.
Save rpbaltazar/069bc1a1e81ebe9b8eb7 to your computer and use it in GitHub Desktop.
Multiline text wrapping using css (webkit only)
#parent-element {
/* Breaking this into main wrapper and truncate
allows you to have content that you actually
truncate and some other that you don't */
.main-wrapper {
height: 160px;
}
.truncate {
p {
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
max-width: 100px; /*the max-width can be inehrited from other elements, not being necessary to be here*/
}
}
}
#parent-element
.main-wrapper
.some-nice-class
%p
%span this is some text
%span some more text that we need to show
.truncate
%p and this is the text that we want to truncate with multiple lines
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment