背景:小程序富文本里面用到的table需要固定头部
总结如下,重要:
tbody>tr, thead{
display: table;
width: 100%;
table-layout: fixed;
}
tbody{
display: block;
max-height: 200px;
overflow: auto;
}
tbody>tr>td{
width: 100rpx;
word-break: break-all;
}
参考来源以下文章,赞
tbody设置超出固定的高度出现滚动条,没超出不显示。