Last active
August 29, 2015 14:24
-
-
Save nkpgardose/d1f942ba76b1918629be to your computer and use it in GitHub Desktop.
Clamping is the king. Ellipsis gaming
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
.clamp { | |
overflow: hidden; | |
} | |
.clamp.is-active { | |
position: relative; | |
height: 7em; | |
} | |
.clamp.is-active:after { | |
content: ""; | |
text-align: right; | |
position: absolute; | |
bottom: 0; | |
right: 0; | |
height: 1.2em; | |
background: linear-gradient(to right, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1) 50%); | |
} | |
@supports (-webkit-line-clamp: 4) { | |
.clamp.is-active{ | |
display: -webkit-box; | |
-webkit-line-clamp: 4; | |
-webkit-box-orient: vertical; | |
max-height: 7em; | |
height: auto; | |
} | |
.clamp.is-active:after { | |
display: none; | |
} | |
} |
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
$(document).on('click','.read-more', function(e) { | |
e.stopPropagation(); | |
e.preventDefault(); | |
$(this).parent().find('.clamp').toggleClass('is-active'); | |
}); |
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
<div class="clamp is-active"> | |
<p>...</p> | |
<p>...</p> | |
</div> | |
<p class="clamp is-active">...</p> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment