Я использую таблицу Bootstrap, чтобы показать список с большим количеством столбцов разных размеров. Все было хорошо, но мой клиент попросил включить поле ввода в заголовок столбцов. Это поле при заполнении будет выполнять фильтр для столбца.
Проблема заключается в том, что при вставке поля ввода возникает беспорядок с шириной столбца. Как следствие, теперь каждая строка имеет большую высоту из-за текстовых линий.
Мне нужен вес полей ввода, чтобы соответствовать размеру столбца, и чтобы ширина столбца оставалась такой, как если бы поле ввода не было.
Исходный код более или менее похож на:
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<title>Test</title>
</head>
<body>
<div container>
<table class="table table-striped table-hover table-sm small">
<thead>
<tr>
<th>Project </th>
<th>Line </th>
<th>Code </th>
<th>Pay Item </th>
<th>Code </th>
<th>Material </th>
<th>Accept. </th>
<th>Test </th>
<th>Status </th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<tr>
<td>10D276 </td>
<td>0020 </td>
<td>203.30 </td>
<td>EARTH BORROW </td>
<td>703.02</td>
<td>Earth Borrow</td>
<td>Test</td>
<td>AG-COMP-15</td>
<td>11</td>
<td>
<a href="# " class="zoom"><i class="material-icons" title="Show">zoom_in</i></a>
<a href="# " class="zoom"><i class="material-icons" title="Action">directions</i></a>
</td>
</tr>
<tr>
<td>10D276 </td>
<td>0510 </td>
<td>580.20 </td>
<td>RAPID SETTING CONCRETE REPAIR MATERIAL WITH COARSE AGGREGATE </td>
<td>780.04</td>
<td>Rapid Set Concrete Material with C. Agg</td>
<td>Appd</td>
<td>None_1</td>
<td>4</td>
<td>
<a href="#" class="zoom"><i class="material-icons" title="Show">zoom_in</i></a>
<a href="#" class="zoom"><i class="material-icons" title="Action">directions</i></a>
</td>
</tr>
</tbody>
</table>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</body>
</html>
Я только что поместил таблицу внутри формы и поместил поле ввода внутри заголовков
<form>
<table class="table table-striped table-hover table-sm small">
<thead>
<tr>
<th>Project <input class="form-control form-control-sm" type="text" > </th>
<th>Line <input class="form-control form-control-sm" type="text" > </th>
<th>Code <input class="form-control form-control-sm" type="text" > </th>
<th>Pay Item <input class="form-control form-control-sm" type="text" > </th>
<th>Code <input class="form-control form-control-sm" type="text" > </th>
<th>Material <input class="form-control form-control-sm" type="text" > </th>
<th>Accept. <input class="form-control form-control-sm" type="text" > </th>
<th>Test <input class="form-control form-control-sm" type="text" > </th>
<th>Status <input class="form-control form-control-sm" type="text" > </th>
<th>Actions </th>
</tr>