如何在表格单元格中显示段落

问题描述 投票:0回答:1

我试图在td表格单元格中显示一个小段落问题是该段落不会显示,除非td单元格是灵活的我已经尝试过(white-space:pre和white-space:自动换行) )但它对我不起作用

<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
  border: 1px solid black;
}
</style>
</head>
<body>

<table>
<tr>
 <td style="width: 150px;
             overflow: hidden;
             display: inline-block;
             white-space: word-wrap;"> 
                <div style="width :100px ; white-space: nowrap;">longparagrapgh heeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeey</div>
                  
         
              </td>
 </tr>
</table>

</body>
</html>

任何的想法 ?

html css
1个回答
1
投票

使用word-breakword-wrap

<!DOCTYPE html>
<html>

<head>
  <style>
    table,
    th,
    td {
      border: 1px solid black;
    }
  </style>
</head>

<body>

  <table>
    <tr>
      <td style="width: 150px;
             overflow: hidden;
             display: inline-block;
             white-space: word-wrap;">
        <div style="width :100px ; white-space: normal; word-wrap: break-word; word-break: break-word;">longparagrapgh heeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeey</div>


      </td>
    </tr>
  </table>

</body>

</html>
© www.soinside.com 2019 - 2024. All rights reserved.