HTML:tds 的固定和可变宽度

发布于 2025-01-01 08:29:59 字数 496 浏览 3 评论 0原文

我有一个 和许多 (34)

我想显示三个变量单元格,例如“name”、“hobby1”、“hobby2”,然后我需要显示 31 个单元格(每天)。

的宽度限制为大约 1000px。

在日单元格中,始终应显示长度为 3 的字符串,或者不显示任何内容。

我的问题是,即使使用 css 设置,单元格也永远不会具有相同的宽度。

前三列也可能是固定的。

我如何管理我的表格,让全天 s (1-31) 具有相同的宽度 - 无论内容是空还是 XXX?

http://jsfiddle.net/sBYdu/

i have a <table> and many (34) <td>.

I want to display three variable cells e.g. "name", "hobby1", "hobby2" and then I need to display 31 cells (for each day).

The width of the <table> is limited to about 1000px.

In the day cells always a string of the length 3 shall be displayed or nothing.

My problem is that, the cells never have the same width even if set with css.

The first three columns may be fixed too.

How can I manage my table, that all day <td>s (1-31) have the same width - no matter if the content is nothing or XXX?

http://jsfiddle.net/sBYdu/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

墨小沫ゞ 2025-01-08 08:29:59

添加一些 CSS 就可以实现这一点。

  • 使用固定的表格布局
  • 将宽度应用于表格标题而不是表格单元格
  • 将自动换行应用于表格单元

http://jsfiddle .net/nnePW/

A couple of css additions can achieve this.

  • Use a fixed table-layout
  • Apply width to your table header not the table cell
  • Apply word wrapping to the table cells

http://jsfiddle.net/nnePW/

蓬勃野心 2025-01-08 08:29:59
table {

    table-layout: fixed;
}
table {

    table-layout: fixed;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文