-
-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Any way to make text overflow ellipsis? #270
Comments
You can probably add the overflow css to a parent element that renders the interweave content. |
Hey @milesj, thanks for the response. My particular use case is as follows: I have a Strapi CMS with CKEditor plugin installed which I use to write rich texts for the website. The plugin sends text as raw html which I would like to parse with Interweave and display on the website. CKEditor requires some specific styles for the content to be displayed correctly. I would like to handle cases when the text is long and extends beyond the specified div. This is a snippet that I wrote for illustration purposes |
@colonder Can that sandbox be made public? |
@milesj I made it public, please check again |
Ok I see what you mean. This one is definitely tricky... I don't think this could be solved with CSS alone, you'll probably need JS for it. Basically the JS would work like this:
The other option is to just overflow hidden the parent, and make it look nice. |
Is there any way to easily calculate width and height of each element? |
You would use normal DOM based JS, something like: document.querySelector('#parent').children.forEach(node => {
node.clientWidth;
node.clientHeight;
}); It's been a while since I've done that, so the APIs may be slightly off. |
I found a CSS workaround though not perfect. It requires roughly estimating how much space the text will take...
Otherwise another neat solution is to create an overlay like in here https://css-tricks.com/text-fade-read-more/ |
I wonder whether there is any possibility of adding a text overflow ellipsis to the whole HTML. I looked on the Internet and I know it might be tricky to apply this CSS property to the entirety of the text, or actually, the parent element of all the child tags.
The text was updated successfully, but these errors were encountered: