Solved

Break text, not layout

Posted on 2004-09-17
7
346 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 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Migrating to Exchange 2013 4 42
Cordova Camera plugin fails 2 97
Animated .jpg? 13 61
Randomize in Owl Carousel v1.3.2 6 20
Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

895 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now