Page 1 of 1

Adding a newline automatically to a div

Posted: Tue May 04, 2010 10:51 am
by stom
I have created an editable div box by using the following code.

<DIV id="textdiv" onClick="this.contentEditable='true';">
<PRE>this is the content</PRE>
</DIV>

and the following is the css for it

#textdiv {
position:absolute;
top:30px;
width:600px;
height:670px;
overflow:auto;
background:#DCDCDE;

}

Now when i start entering data into the div, I want it to automatically go to the newline when the data has reached the width size. Now if i keep on entering some characters, the data just keeps on getting added to the right and adds a scroll bar to the div.

Thanks!
Saj

Re: Adding a newline automatically to a div

Posted: Tue May 04, 2010 11:22 am
by rnoack
this isn't really php so i think this is the wrong forum to ask this question.

also i don't know the solution.

Re: Adding a newline automatically to a div

Posted: Tue May 04, 2010 1:04 pm
by flying_circus

Code: Select all

#textdiv {
  position:absolute; 
  top:30px;
  width:600px;
  height:670px;
  overflow:auto; 
  background:#DCDCDE;
  word-wrap: break-word;
}