首页 > 解决方案 > 必须同时使用 max-wdith 和 min-width 而不是仅使用宽度

问题描述

我有一个 html 表格,我需要将单元格设置为特定大小。出于某种原因,我可以实现这一点的唯一方法是将 max-width 和 min-width 设置为相同的值,而不仅仅是宽度。

每个单元格的大小都需要不同,因此我需要在每个单元格上单独设置它。

.corrTable table {
  border-collapse: collapse;
  white-space: nowrap;
}

.corrTable td {
  white-space: nowrap;
  overflow: hidden;
  padding: 5px;
}

.corrTable th {
  padding: 5px;
}

.corrTable>tbody>tr:nth-of-type(odd) {
  border: solid thin;
  /*background-color: #f9f9f9;*/
}
<table class="corrTable" style="min-width:1615px">
  <tr>
    <td id="@i" style="max-width:75px;min-width:75px">@Model.log</td> <!--works-->
    <td id="@i" style="width:75px">@Model.log</td> <!-- does not work -->
    <td id="@i" width="75px">@Model.log</td> <!-- does not work-->
  </tr>
</table>

任何想法?

标签: htmlcssrazor-pages

解决方案


推荐阅读