Last active
August 7, 2023 17:03
-
-
Save Caellian/9901c543943f0f03f63257c1ad1ba2b0 to your computer and use it in GitHub Desktop.
Text ellipsis and line clamping
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
p { | |
display: inline-block; // fallback for CSS4 | |
display: -webkit-inline-box; // specialized renderer supported by all major browsers | |
-webkit-box-orient: vertical; // Required by FF for -webkit-line-clamp | |
-webkit-line-clamp: 1; | |
line-clamp: 1; // Forward CSS4 support | |
font-size: var(--size); | |
line-height: calc(var(--size) * 1.2); // leave wiggle room for descending characters (e.g. jy...) | |
overflow: hidden; // required for ellipsis | |
max-height: 1.2em; // based on font-size; same as above multiplier | |
text-overflow: ellipsis; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment