-2

I have a chat conversation within a div, but very long words fall out. I was advised to use an i-frame, but how? I thought this is for external websites.

jsFiddle Code

CSS

.chat{
   width: 230px;
   height: 310px;
   margin-left: 10px;
   background-color: grey;
   border: solid 1px black;
   color: #1855a3;
   overflow-y: scroll;
}
Axel
  • 10,732
  • 2
  • 30
  • 43
kaputu
  • 141
  • 2
  • 4
  • 10

4 Answers4

17

try to add word-wrap:break-word; in your css

math487
  • 253
  • 1
  • 2
  • 10
3

Add the CSS rule: word-break:break-word;

jsFiddle example

j08691
  • 204,283
  • 31
  • 260
  • 272
1

Use word-wrap: break-word; - works in all browsers.

http://jsfiddle.net/adamh/TWsqQ/5/

Adam Hopkinson
  • 28,281
  • 7
  • 65
  • 99
0

What I believe you're trying to do is prevent horizontal scroll.

You can easily do this with using overflow-x: hidden; and word-wrap: break-word; so that the long words will breaks into a new line.

CSS:

.chat{
   width: 230px;
   height: 310px;
   margin-left: 10px;
   background-color: grey;
   border: solid 1px black;
   color: #1855a3;
   overflow-y: scroll;
   overflow-x: hidden;
   word-wrap: break-word;
}

See an example here: http://jsfiddle.net/TWsqQ/10/

Axel
  • 10,732
  • 2
  • 30
  • 43