gpt4 book ai didi

jquery - 动态调整列大小的css

转载 作者:行者123 更新时间:2023-11-28 05:10:08 24 4
gpt4 key购买 nike

以下是我拥有的 html 表格代码。

    .table_header
{
text-align: center;
width:50px;
vertical-align: middle;
background-color: gainsboro;
}
  <table>
<tr>
<th class="table_header"></th>
<th class="table_header">header 1</th>
<th class="table_header">header 2</th>
</tr>
<tr>
<td class="table_header">very large row header 1</td>
<td><input class="qty_input" value="0" type="text"/></td>
<td><input class="qty_input" value="0" type="text"/></td>
</tr>
<tr>
<td class="table_header">row header 2</td>
<td><input class="qty_input" value="0" type="text"/></td>
<td><input class="qty_input" value="0" type="text"/></td>
</tr>
</table>

第一列正确设置为 50px。但是所有其他列都有不同的大小。所以我为 td 和输入字段提供了宽度为 40px 的样式。它部分修复了,但问题是当行标题名称 id 的长度很大时,调整了它的高度,但输入字段保持不变。我注意在行标题大小增加时也调整输入字段。

输入字段用于保存浮点值。所以需要小宽度否则表格会变大

最佳答案

使用theadtbody。试试这个标记:

<table>
<thead>
<tr>
<th class="table_header">header 1</th>
<th class="table_header">header 2</th>
<th class="table_header">header 3</th>
</tr>
</thead>
<tbody>
<tr>
<td class="table_header">very large row header 1</td>
<td><input class="qty_input" value="0" type="text"/></td>
<td><input class="qty_input" value="0" type="text"/></td>
</tr>
<tr>
<td class="table_header">row header 2</td>
<td><input class="qty_input" value="0" type="text"/></td>
<td><input class="qty_input" value="0" type="text"/></td>
</tr>
</tbody>
</table>

关于jquery - 动态调整列大小的css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39610722/

24 4 0
文章推荐: html - 更改选定链接的 BG 颜色
文章推荐: javascript - 为什么我的标签代码不能正常工作?
文章推荐: javascript - 卡在粘性 header 上
文章推荐: javascript - 单击按钮将不同的图片加载到一个
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com