如何使用 HTML 使 select 框在单元格 table 中居中?
How to center a select box in a cell table using HTML?
这可能看起来很傻,但我是这里的初学者,我无法解决这个问题:
<table class="table table-sm table-striped" id="dtable" style="font-size:0.9em">
<thead style="white-space: nowrap">
<tr>
<th style="width: 17%" class="text-center">Link To File</th>
<th style="width: 18%" class="text-center">Approval Status</th>
</thead>
<tbody>
<tr>
<td class="align-middle" style="word-wrap: break-word;min-width: 160px;max-width: 160px;text-align:center">2</td>
<td class="align-middle" style="align-center">
<select name="D1" style="border-radius: 0.2rem">
<option value="empty"></option>
<option value="approved">Approved</option>
<option value="dicsuss">Discuss</option>
<option value="cancelled">Cancelled</option>
</select>
</td>
</tr>
</tbody>
</table>
它应该是这样的:
感谢任何帮助。
假设您正在使用 bootstrap
改变这个:
<td class="text-center">
<select class="text-center" name="D1" style="border-radius: 0.2rem">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<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://cdn.jsdelivr.net/npm/popper.js@1.12.9/dist/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<table class="table table-sm table-striped" id="dtable" style="font-size:0.9em">
<thead style="white-space: nowrap">
<tr>
<th style="width: 17%" class="text-center">Link To File</th>
<th style="width: 18%" class="text-center">Approval Status</th>
</thead>
<tbody>
<tr>
<td class="align-middle" style="word-wrap: break-word;min-width: 160px;max-width: 160px;text-align:center">2</td>
<td class="text-center">
<select class="text-center" name="D1" style="border-radius: 0.2rem">
<option value="empty"></option>
<option value="approved">Approved</option>
<option value="dicsuss">Discuss</option>
<option value="cancelled">Cancelled</option>
</select>
</td>
</tr>
</tbody>
</table>
这可能看起来很傻,但我是这里的初学者,我无法解决这个问题:
<table class="table table-sm table-striped" id="dtable" style="font-size:0.9em">
<thead style="white-space: nowrap">
<tr>
<th style="width: 17%" class="text-center">Link To File</th>
<th style="width: 18%" class="text-center">Approval Status</th>
</thead>
<tbody>
<tr>
<td class="align-middle" style="word-wrap: break-word;min-width: 160px;max-width: 160px;text-align:center">2</td>
<td class="align-middle" style="align-center">
<select name="D1" style="border-radius: 0.2rem">
<option value="empty"></option>
<option value="approved">Approved</option>
<option value="dicsuss">Discuss</option>
<option value="cancelled">Cancelled</option>
</select>
</td>
</tr>
</tbody>
</table>
它应该是这样的:
假设您正在使用 bootstrap
改变这个:
<td class="text-center">
<select class="text-center" name="D1" style="border-radius: 0.2rem">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<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://cdn.jsdelivr.net/npm/popper.js@1.12.9/dist/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<table class="table table-sm table-striped" id="dtable" style="font-size:0.9em">
<thead style="white-space: nowrap">
<tr>
<th style="width: 17%" class="text-center">Link To File</th>
<th style="width: 18%" class="text-center">Approval Status</th>
</thead>
<tbody>
<tr>
<td class="align-middle" style="word-wrap: break-word;min-width: 160px;max-width: 160px;text-align:center">2</td>
<td class="text-center">
<select class="text-center" name="D1" style="border-radius: 0.2rem">
<option value="empty"></option>
<option value="approved">Approved</option>
<option value="dicsuss">Discuss</option>
<option value="cancelled">Cancelled</option>
</select>
</td>
</tr>
</tbody>
</table>