CSS: how can I force a long string (without any bl

2019-01-04 17:47发布

I have a long string (a DNA sequence). It does not contain any whitespace character. e.g.:

ACTGATCGAGCTGAAGCGCAGTGCGATGCTTCGATGATGCTGACGATGCTACGATGCGAGCATCTACGATCAGTCGATGTAGCTAGTAGCATGTAGTGA

what would be the css selector to force this text to be wrapped in an html:textarea or in a xul:textbox

14条回答
男人必须洒脱
2楼-- · 2019-01-04 18:17

Here are some very useful answers:

How to prevent long words from breaking my div?

to save you time, this can be solved with css:

white-space: -moz-pre-wrap; /* Mozilla */
white-space: -hp-pre-wrap; /* HP printers */
white-space: -o-pre-wrap; /* Opera 7 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: pre-wrap; /* CSS 2.1 */
white-space: pre-line; /* CSS 3 (and 2.1 as well, actually) */
word-wrap: break-word; /* IE */
word-break: break-all;
查看更多
我只想做你的唯一
3楼-- · 2019-01-04 18:17
<textarea style="width:100px; word-wrap:break-word;">
  place your text here
</textarea>
查看更多
戒情不戒烟
4楼-- · 2019-01-04 18:17

just setting width and adding float worked for me :-)

width:100%;
float:left;
查看更多
祖国的老花朵
5楼-- · 2019-01-04 18:17

In a case where the table isnt of fixed size, below line worked for me:

style="width:110px; word-break: break-all;"
查看更多
何必那么认真
6楼-- · 2019-01-04 18:18

Place zero-width spaces at the points where you want to allow breaks. The zero-width space is &#8203; in HTML. For example:

ACTGATCG&#8203;AGCTGAAG&#8203;CGCAGTGC&#8203;GATGCTTC&#8203;GATGATGC

查看更多
\"骚年 ilove
7楼-- · 2019-01-04 18:18

Use <wbr>tag:

ACTGATCG<wbr>AGCTGAAG<wbr>CGCAGTGC<wbr>GATGCTTC<wbr>GATGATGC

I think this is better than using zero-width space &#8203; which could cause problems when you copy the text.

查看更多
登录 后发表回答