You can implement a similar UI in your web-based applications, by using the CSS text-overflow attribute. This is what you need to do:
- Ensure that the text you want to clip is encapsulated in <nobr> </nobr> tags or set the white-space style attribute of the tag containing your text to nowrap
- In the style attribute of your container tag – say div, set the width attribute to your desired width
- In the style attribute of your container tag, set the text-overflow attribute to “ellipsis” and overflow attribute to hidden.
Let’s see a quick example of this in action.
Unfortunately, cropping text will not give you tooltips automatically. You can set the title attribute of the div to get the tooltips. Tooltips in web UIs is another interesting topic. I’ll take it up tomorrow!
1 comment:
Exactly my point - "Unfortunately, cropping text will not give you tooltips automatically. You can set the title attribute of the div to get the tooltips." - In the example that I have put up, I haven't set the title property of the div (do a view-source) - so FireFox or not you won't get tooltips.
Mozilla doesn't support it yet - it'll just clip the text and not show ellipisis. To be fair to them - its an IE specific extension to CSS.
Post a Comment