如何自动调整HTML表格单元格以适合文本大小 [英] How to Auto resize HTML table cell to fit the text size

查看:417
本文介绍了如何自动调整HTML表格单元格以适合文本大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个有2行和可变列的表。我试过width = 100%的列。所以视图中的第一个内容会合适。但是假设如果我动态地更改内容,那么它不是动态增加/减少HTML表列大小。
提前感谢。

I have a table with 2 rows and variable columns. I tried width = 100% for the column. So the first content in the view will fit. But suppose if i am changing the contents dynamically then it is not dynamically increase/decrease the HTML table column size. Thanks in advance.

推荐答案

如果你想根据内容调整单元格大小,

If you want the cells to resize depending on the content, then you must not specify a width to the table, the rows, or the cells.

如果您不想要换行,请指定CSS样式 white-space :nowrap 到单元格。

If you don't want word wrap, assign the CSS style white-space: nowrap to the cells.

这篇关于如何自动调整HTML表格单元格以适合文本大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆