473,672 Members | 2,772 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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?

Here's a snippet that I'm working on:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>untitled </title>

<style><!--
..dots {
width: 50%;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
padding: 1px 6px;
background-color: #eee;
}
--></style>
<script language="JavaS cript">
<!--
//-->
</script>

</head>
<body>
#1 Below is a sentence enclosed in a normal DIV tag.
<div STYLE="width:75 %;background-color:yellow;pa dding:5px;borde r:1px
solid black" title="full text here"> <nobr>As you can see, this would
work very well in the interface, and as more browsers support it, could
easily become the preferred presentation style for users.
</nobr></div>

<P>
#2 And here is that same sentence in a DIV tag which has the
<B>text-overflow:ellips is</B> style attribute<BR>(a s well as
overflow:hidden ) and nobr.
<div STYLE="width:55 %;white-space:nowrap;pa dding:5px;borde r:1px solid
black;overflow: hidden;text-overflow:ellips is"> As you can see, this
would work very well in the interface, and as more browsers support
it, could easily become the preferred presentation style for users.
</div>
<P>
#3 And here is that same sentence in a DIV tag which has the
<B>text-overflow:ellips is</B> style attribute<BR>(a s well as
overflow:hidden ) without nobr.
<div STYLE="width:55 %;background-color:yellow;pa dding:5px;borde r:1px
solid black;overflow: hidden;text-overflow:ellips is"> <nobr>As you can
see, this would work very well in the interface, and as more browsers
support it, could easily become the preferred presentation style for
users. </nobr></div>

<P>
#4 And here is that same sentence in a SPAN tag </p>
does not work<br>
<span CLASS="dots"> <nobr>As you can see, Span isn't working, why might
that be? and as more browsers support it, could easily become the
preferred presentation style for users. </nobr></span>

</body>
</html>

references for help:
http://wiki.fastmail.fm/wiki/index.p...erflowEllipsis
this example:
http://joelpt.eml.cc/TextOverflowEllipsis.html or this one:
http://robm.fastmail.fm/web/table_autosize.html

and this posting:
http://groups.google.com/group/comp....f5e54642377323

Dec 12 '05 #1
4 23458
ja******@gmail. com wrote:
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
Dec 12 '05 #2
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.getEle mentById(id);
var spans = d.getElementsBy TagName('span') ;
for (var i=0, len=spans.lengt h; i<len; ++i){
addEllipsis(spa ns[i]);
}
}
function addEllipsis(d)
{
var x = d.parentNode.of fsetWidth;
var txt = d.firstChild.da ta;
while (x < d.offsetWidth){
txt = txt.substring(0 ,txt.length-1);
d.firstChild.da ta = txt + '\u2026';
}
}
</script>
<!-- Style attribute wrapped for posting -->
<div id='divA')
style="border:1 px 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="trimMe nu('divA')">
(courtesy this thread, thanks Rob
http://groups.google.com/group/comp....f5e54642377323)

Thanks!

Dec 12 '05 #3
ja******@gmail. com wrote:
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.
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
Dec 12 '05 #4
Thank you very much Spartanicus for the assistance. I'll direct the
question to the microsoft.* groups.

Dec 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
6322
by: igorsl | last post by:
Hi, I have a problem to insert(update) a long text (more than 64K) into SQL 2000 (datatype - 'text'). It cuts the data and insert only 64K. MSDN says: "When the ntext, text, and image data values get larger, however, they must be handled on a block-by-block basis. Both Transact- SQL and the database APIs contain functions that allow applications to work with ntext, text, and image data block by block." Could somebody
4
9263
by: Web Team | last post by:
Hi All, I'm trying to stop text from wrapping in a span, so that my users can enter content with out the box stretching across the screen when they reach the edge of it, and with out horizontal scroll bars appearing. Basically replicating notepad with word wrap switched on. Maybe this isnt possible? Any help will be much appreciated.
4
1970
by: R Bolling | last post by:
I have a text file from a text document that has very long rows (two or three paragraphs from a text document for each row). Importing to text cuts it off at 255 characters, and importing to a memo still cuts it short. TransferText cut it short too. Someone suggested that I use the following code. It works, but it populates only one row of the text. Missing something critical. Any ideas on how to get this to work? 'Beginning of...
2
10616
by: JA | last post by:
Why do I sometimes get the error "the text is too long to be edited" when trying to work directly in a memo field in Access 2000? Is there a way to make that go away? Thanks, JA
3
2248
by: Neal Miller | last post by:
Hi Thanks to all of your help, I've got a working PrintRTF module that prints out RTF code, and it works well. The next issue to overcome is to determine how to page-break text that is too long for one page Is there some way to identify exactly how many characters I can print before I run out of room in the current rectangle that defines the output, and do to a new page. A VB.NET code sample with a loop to handle multiple pages would be...
17
4708
by: pigeonrandle | last post by:
Hi, I have seen loads of different ways to do this, but the all seem to yield the same result - text that doesn't flicker when it's moving too slowly! Does anyone know 'the best way' to make text scroll... eg Override OnPain and OnPaintBackground Override WndProc
5
4931
by: Bluecove | last post by:
After many unsuccessful attempts at this, including the use of software from Sobolsoft, I need help! I have a table comprised of thousands of long records (all in one column which is Memo type). These records are from an old Dos-based database. I need to extract text from each memo fields and put it into it's proper place. For example, a part of the memo field looks like this: <A>JOYCE, James.<T>Dubliners<DATE>1933<PUB>..etc. I need to strip...
1
5758
by: duzhidian | last post by:
Hello: I just want to use a two columns web. If I put sidebar on the right, it there is a list, it's fine. If it is a paragraph, the width will not work? Why? In the following example, width is 200 px, but the contents is much long than that.
6
4476
by: liketofindoutwhy | last post by:
There is a link that encloses a span (or a div), but the link won't work in IE 7 (clicking on video image works, but not on the play button), while it works well in Firefox 2 and 3, and Safari 3. The intention is to make the link clickable on both the play button and the video image. the page is http://www.0011.com/test/test_link.html the code
0
8486
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8932
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8683
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7449
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6240
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5707
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4419
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2821
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2064
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.