문제

Let say I have this paragraph

iamaverylongwordthathasnospace yehey

when i use word-wrap:break-word; it became

iamaverylongwordthathas
nospace yehey

This is good..but when I tried

iama verylongwordthathasaspace yehey

It became

iama
verylongwordthathasaspace
yehey

My question is how to make the paragraph look like this

iama verylongwordthathas
nospace yehey

It will wrap on spaces but force to break on long words?

도움이 되었습니까?

해결책

You are looking for word-break: break-all;

Here is an example. I put the background as black, so you can see where it breaks: JS Fiddle

HTML

<div>iama verylongwordthathasaspace yehey</div>

CSS

div {
    width: 120px;
    word-break: break-all;
    background: black;
    color: white;  
}

Source: CSS-Tricks: Word-break

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top