Last active
June 10, 2024 07:42
-
-
Save ChristianOellers/11aebc89d659fbe3a3ac7e9c54c656fa to your computer and use it in GitHub Desktop.
CSS line length cap (Specific number + Equal heights)
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
/** | |
* Example: Cap text at a specific line length. | |
* Especially useful for e.g. card/ tile layouts with different content but equal heights. | |
*/ | |
.text-overflow { | |
--lines: 3; | |
height: calc(var(--lines) * 1.25rem); | |
font-size: 1rem; | |
line-height: 1.25rem; | |
overflow: hidden; | |
text-overflow: ellipsis; | |
display: -webkit-box; | |
-webkit-line-clamp: var(--lines); | |
-webkit-box-orient: vertical | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment