gpt4 book ai didi

javascript - 适合 TH 单元格内的选择字段

转载 作者:太空宇宙 更新时间:2023-11-04 13:32:25 24 4
gpt4 key购买 nike

我在 PHP 中有一个函数可以根据 MySQL 查询的结果创建一个表。我还添加了一个 javascript 类来根据列过滤行,但此函数为每列创建了一个具有唯一数据的隐藏选择。当我显示那些选择字段时,它们会改变列的宽度,但它们的宽度应该来自 TD 单元格的内容,而不是来自选择...

为什么我要限制选择字段以适应 TH 单元格而不改变其宽度?

<table>
<thead>
<tr>
<th>Index
<th>Column 1 <br> <select><option>Ble</option><option>Bigger</option></select>
<th>Col2 <br> <select><option>Bla</option><option>Big option blablabla</option></select>
</tr>
</thead>
<table>

我试过 CSS:

次选择{ 宽度:100%

附加的:

<th class="table-sortable:alphanumeric table-filterable table-sortable" table-sortable:alphanumeric="" table-filterable="" title="Click to sort">Resposta
<br><select onchange="Table.filter(this,this)" onclick="Table.cancelBubble(event)" class="table-autofilter" style="display: inline-block;">
<option value="">Filter: All</option>
<option value="1">1</option>
<option value="NAO">NAO</option>
<option value="SEPLAG">SEPLAG</option>
<option value="SIM">SIM</option>
</select>
</th>

示例打印:https://www.dropbox.com/s/cah2igqt40kq0vm/tables.png

好的,解决了...

我刚刚在选择字段上添加了 CSS:

margin: 0 -45 0 -45;

最佳答案

您可以为选择的标签添加样式:

<select style="width:300px;">

这会将选择的宽度设置为 300 像素。如果你使用

<select style="width:100%;">

它将选择宽度设置为其父级()留下的可用空间。

问候,

关于javascript - 适合 TH 单元格内的选择字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23270644/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com