Today I Learned - Rocky Kev

TIL Truncating text with Ellipsis

POSTED ON:

TAGS:

You know you get a body of text, but you only want a specific amount to be shown?

Example:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut nec iaculis enim. Nam sagittis laoreet tellus, ac dapibus erat. Aliquam venenatis auctor elit eget sollicitudin. Nullam vulputate varius ante eu hendrerit. Nullam malesuada sem sapien, ut mollis nisi efficitur in. Nullam metus velit, aliquam non posuere non, vulputate quis diam. Aenean efficitur, mi non mollis sollicitudin, nulla nulla convallis ante, id scelerisque nisi arcu at est. Integer efficitur turpis nec tortor finibus, eu vehicula libero aliquam. Vivamus consequat lorem ac massa maximus, vel semper nibh vehicula.

becomes

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut nec iaculis enim. Nam sagittis laoreet tellus, ac dapibus erat. Aliquam venenatis auctor elit eget sollicitudin. Nullam vulputate varius ante eu hendrerit. Nullam malesuada sem sapien, ut mollis nisi efficitur in. Nullam metus velit, aliquam non posuere non...

You can do that here:

.line-clamp {
display: -webkit-box;
-webkit-line-clamp: 3;
overflow: hidden;
-webkit-box-orient: vertical;
}

If your build tool is removing webkid-box-orient,
that's because your tool sees webkit-bot-orient as outdated, and is automatically removing it.

But, this specific process is implemented in all browsers (hacky and all).

To make it work, do this:

/* autoprefixer: off */
-webkit-box-orient: vertical;
/* autoprefixer: on */
...

via:
https://css-tricks.com/line-clampin/


Related TILs

Tagged:

TIL the alternate keyword

If 'alternate' appears along with the stylesheet keyword, the linked file is an alternative stylesheet. It won’t be applied to the document, but it will be ready for when we need it.

TIL Logical Properties

For that sweet sweet Internationalization you want to avoid directional words like 'left', 'right', 'top', and 'bottom'.

TIL Using pseudo-classes in your querySelector!

let notTuna = document.querySelectorAll('.sandwich:not(.tuna)')