Frage

I have a div and bulk of content loaded into this div. I applied some CSS style for managing the div width: `word-break: break-all; word-wrap: break-word;

but after applying this css the div alignment was disturbed, because I noticed some words are truncating after this.

My css is:

width: 98%;
word-break: break-all;
word-wrap: break-word;
text-align: justify;

I did't understand how can I get justify align text with those css, How can i overcome this problem? Can any one suggest me to another CSS style to resolve this problem?

See in jsfiddle

Thank you...!!Here the image of my div with truncated words at the end

War es hilfreich?

Lösung 3

Finally, I find-out some CSS style which help me to overcome my problem:

CSS:

    width : 440px;
    white-space: pre;           /* CSS 2.0 */
    white-space: pre-wrap;      /* CSS 2.1 */
    white-space: pre-line;      /* CSS 3.0 */
    white-space: -pre-wrap;     /* Opera 4-6 */
    white-space: -o-pre-wrap;   /* Opera 7 */
    white-space: -moz-pre-wrap; /* Mozilla */
    white-space: -hp-pre-wrap;  /* HP Printers */
    word-wrap: break-word;
    -moz-hyphens:auto; 
    -webkit-hyphens:auto; 
    -o-hyphens:auto; 
    hyphens:auto;
    text-align: justify;   

Andere Tipps

Html way of doing the same would be adding <wbr> before/after/embedded in your long word

wbr:after { content: "\00200B" }

for doing it css way

Here's the html code

<div id="Content">
TestTestTest TestTestTest TestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTest TestTestTest TestTestTestTest ################################################ TestTestTestTest TestTestTest TestTestTest TestTestTest TestTestTest TestTestTest TestTestTest TestTestTestTest TestTestTest TestTestTestTest TestTestTest TestTestTest TestTestTest TestTestTest TestTestTest TestTestTest TestTestTestTest TestTestTest TestTestTestTest T </div>    

and here's your fiddle. words dont break here specially the # i used to check. Please see that you do't enter a new line character like pressing enter

fiddle

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top