Force Long Strings to Wrap
Page 1 of 112 Replies - 73516 Views - Last Post: 16 December 2010 - 06:03 AM
#1
Force Long Strings to Wrap
Posted 15 April 2005 - 01:50 PM
f I have a long string of text in say a table cell, how can I make it break so it doesn't cause horizontal scrolling? Thanks
Replies To: Force Long Strings to Wrap
#2
Re: Force Long Strings to Wrap
Posted 15 April 2005 - 02:14 PM
add
example:
Result:
I like fish. I like them a lot.
Result:
I like fish.
I like them a lot.
<br>
example:
<P>I like Fish. I like them a lot.</P>
Result:
I like fish. I like them a lot.
<P>I like fish. <br>I like them a lot.</P>
Result:
I like fish.
I like them a lot.
This post has been edited by FernFerret: 15 April 2005 - 02:17 PM
#3
Re: Force Long Strings to Wrap
Posted 15 April 2005 - 02:18 PM
Yes that would work
but I want it to break wherever it needs to depending on the users browser, screen size, and text dispaly settings. I hope that makes sense. BTW I mean a string of text like so:
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
This post has been edited by DanceInstructor: 15 April 2005 - 02:20 PM
#4
Re: Force Long Strings to Wrap
Posted 15 April 2005 - 02:24 PM
Sorry I assumed u knew <br> but u never kno
I bet that would be easier in php, I kno a little, but not much.
I bet that would be easier in php, I kno a little, but not much.
#5
Re: Force Long Strings to Wrap
Posted 15 April 2005 - 02:53 PM
IIRC there is some CSS thing you can do. Though at this time I cannot remember what it is.
#6
Re: Force Long Strings to Wrap
Posted 15 April 2005 - 03:06 PM
uhh... Thanks hotsnoj
#8
Re: Force Long Strings to Wrap
Posted 15 April 2005 - 03:49 PM
http://www.cs.tut.fi/~jkorpela/html/nobr.html said:
but it is best to avoid long strings that contain no spaces.
Pretty much the same response I got at DaniWeb.
Thanks everyone for replying.
#9
Re: Force Long Strings to Wrap
Posted 15 April 2005 - 04:27 PM
How are you getting the data for that cell? If it's coming from a database, you can wrap it as you print it. PHP has a built in word wrap
You can also write a word wrap function in any scripting language.
wordwrap($texttowrap, 40, "<br/>", 1); //the 40 represents the number of characters max
You can also write a word wrap function in any scripting language.
#10
Re: Force Long Strings to Wrap
Posted 15 April 2005 - 05:01 PM
i thought it was possible to make a cell not expand width wise no matter what was in it?
#11
Re: Force Long Strings to Wrap
Posted 15 April 2005 - 08:27 PM
supersloth said:
i thought it was possible to make a cell not expand width wise no matter what was in it?
You would think that if you specify the width, then it would be that width no matter what....
Here is some code that I was playing with:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1"/> <title>Variables</title>
<style>
.var_name { width: 250px; overflow: hidden; }
.var_value { width: 500px; overflow: hidden; }
table { width: 750px; }
</style>
</head>
<body>
<table border="1" >
<tr>
<td class="var_name">stuff</td>
<td class="var_value">01234567891123456789212345678931234567894123456789512345678912345678971234567898123456789912345678901234567891123456789212345678931234567898</td> </tr>
</table>
</body>
</html>
Yes I will deal with it in php, but why should I have to lol? Just seems like there should be a css/html way to deal with something like this.
Thanks everyone
#12 Guest_James*
Re: Force Long Strings to Wrap
Posted 18 October 2010 - 01:08 PM
I know this was posted in 2005, but if anyone comes here looking for an answer, as I did, here is what you can do Inside the table
Set the CSS property table-layout to fixed (this might have not been supported in 2005 I dont know). The cell width is now controlled by the specified width rather than the content inside. If you have long string you will need to use overflow: hidden, to stop the text from coming over into other cells.
In CSS3 you can use text-overflow: ellipsis which makes the 3 dots '...' if the text is too long. But this is not fully supported yet
Thanks
Set the CSS property table-layout to fixed (this might have not been supported in 2005 I dont know). The cell width is now controlled by the specified width rather than the content inside. If you have long string you will need to use overflow: hidden, to stop the text from coming over into other cells.
In CSS3 you can use text-overflow: ellipsis which makes the 3 dots '...' if the text is too long. But this is not fully supported yet
Thanks
#13 Guest_RWAP Services*
Re: Force Long Strings to Wrap
Posted 16 December 2010 - 06:03 AM
If anyone is still looking for an answer to this - try adding the css style:
word-wrap: break-word;
It seems to work in most modern browsers, but not sure it will be supported on all!
word-wrap: break-word;
It seems to work in most modern browsers, but not sure it will be supported on all!
Page 1 of 1
|
|

New Topic/Question
Reply


MultiQuote






|