开发者

Indent wrapped text in table

I am creating a table in a html document. If the text is too long in a cell, I want it to wrap on to a new line (no problem). What I am struggling to achieve is making the text on the new line(s) to be indented.

E.g. instead of

A very long bit |
of text in this |
table           |

I want开发者_开发问答:

A very long bit |
   of text in   |
   this table   |

Is it possible to achieve this in CSS or other means?


td {
   text-indent: -4.0em;
   padding-left: 4.0em;
}

This indents the entire cell text and then pulls the first line back to the original left side.


How smart do you need it to be? You could do something simple (and dirty in my example):

s = "a long string";
regExp = /(.{5})(.*)/;
cut = s.replace(regExp, "$1<p>$2</p>");

Then indent or add padding to the text inside the paragraph. Of course this will only work for the first occurrence.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜