wrapping the text inside div - css

2019-02-07 17:24发布

I am having issues with wrapping. I am generating some hexencoding encryption and the output is too long like ;

827938828ey823876te37257e5t328er6367r5erd663275e65r532r6s3624e5645376er563rdr753624e544341763r567r4e56r326r5632r65sr32dr32udr56r634r57rd63725

and it continues. When I put it inside a div, it wont wrap it even if I assign a specific width because they are all together. I want it to continue from the next line if the div is not enough for one line.

how can I do that?

标签: html css wrap
2条回答
在下西门庆
2楼-- · 2019-02-07 18:06

You can't wrap that text as it's unbroken without any spaces. You need a JavaScript or server side solution which splits the string after a few characters.

EDIT

You need to add this property in CSS.

word-wrap: break-word;

查看更多
姐就是有狂的资本
3楼-- · 2019-02-07 18:13

I have found something strange here about word-wrap only works with width property of css properly.

HTML:

<b>This is the example of word-wrap only using width property</b>
<p id="ONLYwidth">827938828ey823876te37257e5t328er6367r5erd663275e65r532r6s3624e5645376er563rdr753624e544341763r567r4e56r326r5632r65sr32dr32udr56r634r57rd63725</p>
<br/>
<b>This is the example of word-wrap without width property</b>
<p id="wordwrapWITHOUTWidth">827938828ey823876te37257e5t328er6367r5erd663275e65r532r6s3624e5645376er563rdr753624e544341763r567r4e56r326r5632r65sr32dr32udr56r634r57rd63725</p>
<br/>
<b>This is the example of word-wrap with width property</b>
<p id="wordwrapWITHWidth">827938828ey823876te37257e5t328er6367r5erd663275e65r532r6s3624e5645376er563rdr753624e544341763r567r4e56r326r5632r65sr32dr32udr56r634r57rd63725</p>

CSS:

#ONLYwidth{
   width:200px;
}

#wordwrapWITHOUTWidth
{   
    word-wrap: break-word;
}

#wordwrapWITHWidth
{   
    width:200px;
    word-wrap: break-word;
}

here is a working demo that i have prepared about it. http://jsfiddle.net/Hss5g/2/

I know its too late but it could help others!

查看更多
登录 后发表回答