Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Break text, not layout

Posted on 2004-09-17
7
Medium Priority
?
354 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 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

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…
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
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:
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

636 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