문제

I have a div with a long text inside it that destroys my layout arrangement. Is there any way to split the words by any logic?

<div style="width:100px">thisdivmessesupmylayoutwithitslongchildtext</div>
도움이 되었습니까?

해결책

Here's the way to do it:

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

Using word-wrap: break-word; we can force the long word to move down a line when it reaches the parent width.

Note: word-wrap is a CSS3 property.

다른 팁

set "width:auto" and "word-wrap:break-word"

this code will set the content in div as per the screen size..as contents in div reaches to right end of screen it will go to next line.

<div style="width:auto;word-wrap:break-word">thisdivmessesupmylayoutwithitslongchildtext</div>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top