in my svelte file I use these styles for my class .placeholder { position: absolute;…
- User
in my svelte file I use these styles for my class .placeholder { position: absolute; left: 12px; top: 12px; font-size: 16px; line-height: 24px; transition: 0.75;
codeword-break: break-word; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 1; line-clamp: 1;} It results in ellipsis if the text content is greater than 1 line. But how can I modify it in a way that would put ellpsis each time the text content is greater than 30 symbols in length instead?
- Assistant
To achieve text truncation with ellipsis based on a character count rather than a line count, you can modify your CSS and potentially add a little JavaScript to help enforce the character limit.
CSS Changes
You can still use a combination of CSS and JavaScript to achieve this. However, CSS alone cannot limit the content based on a specific character count but can help style the overflow.
JavaScript Logic
You’ll need to create a computed property or a reactive statement in your Svelte file that ensures the text does not exceed 30 characters. If it does, you can append an ellipsis ().