Solved

Break text, not layout

Posted on 2004-09-17
7
351 Views
Last Modified: 2012-05-05
I have some long text that is breaking my css layout.  How can I make it wrap when it gets to the right side of its box NO MATTER WHAT?  I've tried using vbscript (asp) to insert line breaks every 100 characters, but that's not working so well.  I could use JavaScript.  The ideal solution would be a css property or something.   Thanks!

Here's an example (gotta love the line art)
The 3 column css layout
------------------
|    |        |     |
|    |        |     |
|    |        |     |
|    |        |     |
------------------

With long text:
------------------
|    |BREAK!
|    |        ____
|    |        |     |
|    |        |     |
-----         |     |
                -----
------------------
   
0
Comment
Question by:dbMe
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 36

Accepted Solution

by:
Zyloch earned 125 total points
ID: 12085565
Hi dbMe,

For CSS, there's the IE-only word-wrap:

word-wrap:break-word;

The only other way with Mozilla and NS, for instance, is to use a Javascript or a server-side. I know that PHP has a wordwrap function but I don't know about ASP.

Regards,
Zyloch
0
 

Author Comment

by:dbMe
ID: 12085620
THAT IS BEAUTIFUL.
Thank you kindly.  How could I do this in JS (in the event that I have do do this for a non-native IE crowd)?
0
 
LVL 36

Expert Comment

by:Zyloch
ID: 12085713
Anything like that will be a little hackish I'm afraid and somewhat estimatable.

You'll probably need to estimate the amount of characters per line, and you'd have to give a fixed font size, like 12pt or something so the user can't change it.

var hl=75;   //say there's 75 characters per line.

function breakWord(wrd) {
   var wrdArray=new Array;
   for (var i=0;i<Math.ceil(wrd.length/75);i++) {
      wrdArray[i]=wrd.substr(75*i,75*(i+1));
   }
   return wrdArray;
}
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:dbMe
ID: 12085746
Thanks a lot.  I also found this link on ASP101.com: http://www.asp101.com/samples/viewasp.asp?file=wordwrap.asp.  It looks like it'll do the trick, although I think you're right, anything like that would be a little hackish.
0
 

Author Comment

by:dbMe
ID: 12085758
That was an easy one eh?
0
 
LVL 36

Expert Comment

by:Zyloch
ID: 12085762
Hopefully, things like these will be fixed in the future, well, glad to help ;)
0
 
LVL 36

Expert Comment

by:Zyloch
ID: 12085770
Somewhat :)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Matthew
I am a very big proponent of technology compliance standards and strive to meet such criteria in all of my work. That includes my site, which is 100% XHTML 1.0 compliant as determined by the World Wide Web Consortium. https://www.matthewstevenkel…
There are two main kinds of selectors in CSS: One is base selector like h1, h2, body, table or any existing HTML tags.  For instance, the following rule sets all paragraphs (<p> elements) to red: (CODE) CSS also allows us to define our own custom …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn how to count occurrences of each item in an array.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question