durian
durian

Reputation: 520

make editable div break line at end of div length

I'm made a div editable using:

<div style="width:100px;" contenteditable="true"></div>

now, i'm putting the content of the div into my db and im extracting it into another page, into a smaller div:

<div style="width:80px;"></div>

if im using the "enter" key while typing - the text breaks lines just fine on the output,

but if im simply writing a long text in the output it leaves the 80px div border.

how can i make the contenteditable div recognize line breaks by its width?

Upvotes: 0

Views: 259

Answers (2)

ygssoni
ygssoni

Reputation: 7359

try with:

<div style="max-width:80px; word-wrap:break-word;"></div>

Upvotes: 3

gaurang171
gaurang171

Reputation: 9080

try this

<div style="width:80px;word-wrap:break-word;"></div>

Upvotes: 0

Related Questions