On a website I am working on users can add a heading to a section of a page.A simple example:
M11-001 - loss of container and goods from Manchester
With some headings the content can be quite in-depth. In reality, for the heading at least, this content isn't always needed. The first few words would suffice to differentiate between records.
I could just set overflow:hidden to the div and ruthlessly cut of anything outside of the set width.
I would prefer to add ... To the end. Like so:
M11-001 - loss of container...
So three full-stops would be added after either X width or X characters.
Is this possible with CSS, or maybe JavaScript?
text-overflow: ellipsis; white-space: nowrap; overflow: hidden; in CSS (or hard-code the style, but CSS is cleaner). If you want to completely cut the text off, use clip instead of ellipsis .
Something like this? http://www.quirksmode.org/css/textoverflow.html
Text-Overflow
The text-overflow declaration allows you to deal with clipped text: that is, text that does not fit into its box. The ellipsis value causes three periods to be appended to the text.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With