有一個包含5列的表格。列可能有不同的寬度(我不分配恆定的寬度)。將輸入寬度綁定到表格列寬度
現在我想在表的頂部創建5個輸入元素。是否有任何訣竅使每個輸入元素的寬度等於相應的列寬?
例如,輸入1應具有第1欄,輸入2的寬度 - 第2欄的寬度等
所以,如何結合輸入列?
UPDATE:
<script>
$('#addButton').click(function() {
$("#addContent").slideToggle("slow");
$('input').width(+$('table td').width()-1);
});
</script>
<div id = "add">
<div id = "addButton" title='New Record' ;>
<img src='images/add.png' alt='New Record' />
</div>
<div id = "addContent">
<input type="text">
<input type="text">
</div>
</div>
<table id="newspaper-b" border="0" cellspacing="2" cellpadding="2" width = "100%">
<thead>
<tr>
<th scope="col">Opr</th>
<th scope="col">Flt Num</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
<?php foreach ($result1 as $row):
$status=$row['status'];
$airlineName=$row['airlineName'];
$flightNum=$row['flightNum'];
?>
<tr id="<?php echo $flightNum; ?>" class="edit_tr">
<td width="80" ><?php echo $airlineName;?></td>
<td width="80" ><?php echo $flightNum;?></td>
<td width="80" id="<?php echo $flightNum; ?>" class="deact_but">
<div>
<img src='images/delete.png' alt='Deactivate' />
</div>
</td>
</tr>
<?php endforeach;?>
</tbody>
</table>
CSS
input{
float: left;
margin: 0;
padding: 0;
}
你試過添加style =「width:100%;」到輸入? –
你打算用php做什麼? – Leri
@ Chris Gessler:請看jFiddle。輸入具有「寬度:100%」。在這種情況下,每個輸入只需要一個表格的寬度。 –