td html中的文本溢出

时间:2014-01-06 07:30:51

标签: html css html-table

p未包含在td中,请参阅下面的演示:

http://fiddle.jshell.net/Grp2Q/

<td align="left" style="padding:0px; width:200px;">
      <img src="http://placehold.it/200x200" />
 </td>

 <td style="padding-left:20px;max-width:100%;">
  <p>dfgdfgggggggggggggggggggggdfgdfgdfsdsdfdfgdfgggggggggggggggggggggdfgdfgsdfsdsdfdfgdfgggggggggggggggggggggdfgdfgsdfsdsdf</p>
 </td>

5 个答案:

答案 0 :(得分:4)

您需要打破文本,为此,使table 修复 width,并使用word-wrap属性,其值为{{1 }}

Demo

break-word

答案 1 :(得分:0)

使用word-break:break-all

demo

<td style="padding-left:20px;max-width:100%;word-break:break-all;">
   <p>dfgdfgggggggggggggggggggggdfgdfgdfsdsdfdfgdfgggggggggggggggggggggdfgdfgsdfsdsdfdfgdfgggggggggggggggggggggdfgdfgsdfsdsdf</p>
</td>

答案 2 :(得分:0)

在段落中添加这样的样式:

.word_wrap {word-wrap:break-word;} 

答案 3 :(得分:0)

试试这段代码:

<强> FIDDLE

<强> CSS

table {
    table-layout: fixed;
    width: 100%;
}

td {
    word-wrap: break-word;
}

答案 4 :(得分:0)

请加上css div table tr td {word-break:break-all;}