PDA

View Full Version : How to stop word wrap in div???



hotwheelharry
May 3rd, 2010, 04:38 AM
How can I make a line of text with or without spaces NEVER jump to the next line unless there is a newline character or a break?

At the moment I tried el.style.wordWrap = "no-wrap";

but it still wraps for text with spaces.


Please help, this is driving me insane.
Thanks.

Edit: preferably something cross browser too. =D

code beginner
May 3rd, 2010, 05:05 AM
try posting the code that is being affected. this seems easy to fix. not sure why you would want text to go past the width of the
screen however.

Excavator
May 3rd, 2010, 05:07 AM
Hello hotwheelharry,
I believe wordwrap is CSS3 so that's not going to be supported cross browser at all.

Give this a try and see if it will do what you're wanting - http://nopeople.com/CSS/nowrap/index.html

hotwheelharry
May 3rd, 2010, 06:34 AM
Thanks Excavator,

I tried white-space: no-wrap and it doesn't work either. :(

Here is some background:

the text is in a contentEditable div and has so many parent elements, i'm a bit lost on where the problem might be in css...

If this helps at all, check out the page i'm working on.
Please not everyone all at once, my server is weak.

This page is built for Chrome or FF, IE has no support yet.

Currently the div is set as "white-space: no-wrap".

Type in the box that says "code here" past the edges and you'll see what i mean.

Direct link:
...

PS: if you have nothing better to do with your time, the js code used is in js/apps/Edit.js and the function is Edit.prototype.BuildUI()

Rowsdower!
May 3rd, 2010, 04:07 PM
What about adding something like this:
white-space:pre;
max-width:678px;
overflow:auto;

hotwheelharry
May 4th, 2010, 01:36 AM
Holy s#!t it worked!

You'd think that i would be able to do it after all that work on everything else.
Guess not, haha.

Thanks dude.