我试图在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>
任何的想法 ?
使用word-break
和word-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>