views:

56

answers:

2

I have a <span> which encloses a very long message

<span>A very long message..........</span>

Can I make the span 's behavior look like a read-only and fixed sized <input type="text"> using CSS or java script ? I want the displayed message will has the fixed length displayed and user can scroll to see the whole message if the message is so long, just like the input control of the following code:

<input type="text" value="A very long message.........." readonly="readonly" size="40" >
+1  A: 

Tadaa!

<input type="text" value="A very long message.........." readonly="readonly" size="40" >
Michael Robinson
+2  A: 

Something like this?

<div style="height:200px;overflow:auto;">text</div>
Webarto
As here you should opt for div tags as these are inherently block elements. This will have vertical and horizontal scrolls enforced. You can just have overflow:auto so scrolls only appear when needed. EDIT: saw you only have spans, in which case you will need to define, display:block in css.
Josh Stuart
Yes, you are right. I used div because it is block element by default.
Webarto