?
Solved

Break text, not layout

Posted on 2004-09-17
7
Medium Priority
?
355 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
  • 4
  • 3
7 Comments
 
LVL 36

Accepted Solution

by:
Zyloch earned 500 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
Technology Partners: 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
It's sometimes a bit tricky to use date functions in Oracle BPEL. I'll explain quickly how you can add N days to the current date. In a BPEL process this can be useful, and you can adapt it to fit your needs. First of all, let's see how to add 1 …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Suggested Courses

850 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