HighDots Forums  

Re: Ellipses nowrap for text that's too long in a span tag

Cascading Style Sheets Layout/presentation on the WWW (comp.infosystems.www.authoring.stylesheets)


Discuss Re: Ellipses nowrap for text that's too long in a span tag in the Cascading Style Sheets forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Spartanicus
 
Posts: n/a

Default Re: Ellipses nowrap for text that's too long in a span tag - 12-12-2005 , 07:48 AM






jawolter (AT) gmail (DOT) com wrote:

Quote:
I have text that is too long to nicely fit on a given page, so I want
to add ellipses to the end that dynamicaly resize based on the person
resizing the page width. If you hover it would show the full text,
using a title attribute I believe.

It works for a div, but not a span... any ideas?
Name: text-overflow-mode
Applies to: block-level and inline-block elements

You do know that CSS3 properties and/or values are likely to fail in
most browsers if used on a www site?

--
Spartanicus


Reply With Quote
  #2  
Old   
jawolter@gmail.com
 
Posts: n/a

Default Re: Ellipses nowrap for text that's too long in a span tag - 12-12-2005 , 07:49 AM






Thanks for the reply, this will be for an intranet site with ie 5 or
greater. according to this:
http://joelpt.eml.cc/TextOverflowEllipsis.html it looks like I could go
down to IE 5 and only loose the ellipses, but still get the
text-overflow: hidden.

I'm not a designer, but a developer who's learning design. Here is a
javascript method... which works pretty well first try... what method
is safer, and/or better: javascript or CSS3 properties?

<script type="text/javascript">


function trimMenu(id)
{
var d = document.getElementById(id);
var spans = d.getElementsByTagName('span');
for (var i=0, len=spans.length; i<len; ++i){
addEllipsis(spans[i]);
}
}


function addEllipsis(d)
{
var x = d.parentNode.offsetWidth;
var txt = d.firstChild.data;
while (x < d.offsetWidth){
txt = txt.substring(0,txt.length-1);
d.firstChild.data = txt + '\u2026';
}
}


</script>


<!-- Style attribute wrapped for posting -->
<div id='divA')
style="border:1px solid blue; width:100px; white-space: nowrap;
overflow: hidden;">
<span>Here is some too-long text</span><br>
<span>Another bit of too-long text</span><br>
<span>Yup, too-long text</span><br>
</div>
<input type="button" value="Trim menu items"
onclick="trimMenu('divA')">
(courtesy this thread, thanks Rob
http://groups.google.com/group/comp....f5e54642377323)



Thanks!


Reply With Quote
  #3  
Old   
Spartanicus
 
Posts: n/a

Default Re: Ellipses nowrap for text that's too long in a span tag - 12-12-2005 , 08:06 AM



jawolter (AT) gmail (DOT) com wrote:

Quote:
Thanks for the reply, this will be for an intranet site with ie 5 or
greater. according to this:
http://joelpt.eml.cc/TextOverflowEllipsis.html it looks like I could go
down to IE 5 and only loose the ellipses, but still get the
text-overflow: hidden.
Ah, I didn't know that this was originally proprietary IE code that
apparently has been adapted into the CSS3 CR.

Quote:
I'm not a designer, but a developer who's learning design. Here is a
javascript method... which works pretty well first try... what method
is safer, and/or better: javascript or CSS3 properties?
This group is dedicated to authoring for the www, questions regarding
developing for a particular client on an intranet should go to a group
dedicated to that client (i.e. a group in the microsoft.* hierarchy).

--
Spartanicus


Reply With Quote
  #4  
Old   
jawolter@gmail.com
 
Posts: n/a

Default Re: Ellipses nowrap for text that's too long in a span tag - 12-12-2005 , 02:58 PM



Thank you very much Spartanicus for the assistance. I'll direct the
question to the microsoft.* groups.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.