fro*_*sty 3 html css html-table max width
我正在尝试设置表的最大宽度,但它似乎不起作用.如果表格中的单词太长,它会自动扩展表格的宽度.我该如何阻止这种情况发生,而是说太长的话会转到下一行呢?
<style>
table {
max-width: 300px;
}
table,td {
border: 1px solid red;
}
div {
border: 1px solid blue;
word-wrap: break-word;
}
</style>Run Code Online (Sandbox Code Playgroud)
<table>
<tr>
<td>
<div> hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello </div>
</td>
</tr>
</table>Run Code Online (Sandbox Code Playgroud)
小智 6
如果要使max-width起作用,则需要table-layout: fixed;在表上设置CSS属性
https://developer.mozilla.org/en-US/docs/Web/CSS/table-layout
| 归档时间: |
|
| 查看次数: |
9748 次 |
| 最近记录: |