固定td单元格的高度和宽度--HTML



我想在我的单元格上设置一个固定的高度和宽度:

如果$elem 上有一个长数组,则表会变大

 <table align="center" class="data_table vert_scroll_table" >
              <tr>
                  <c:forEach var="heading" items="${results.headings}"> 
                      <th class="narrow">${heading}</th>
                  </c:forEach>
              </tr>
              <c:forEach var="row" items="${results.data}">
                  <tr>
                      <c:forEach var="cell" items="${row}" varStatus="rowStatus">
                          <td class="narrow" style="width:75px;height:75;">
                              <c:choose>
                                  <c:when test="${results.types[rowStatus.index].array}">
                                      <c:forEach var="elem" items="${cell}" varStatus="cellStatus">
                                      <span class="mouseover_text" title="${elem},&nbsp;">${elem}<c:if test="${!cellStatus.last}">,&nbsp;</c:if></span>
                                      </c:forEach>
                                  </c:when>
                                  <c:otherwise>
                                          ${cell}
                                  </c:otherwise>
                              </c:choose>
                          </td>
                      </c:forEach>
                  </tr>
              </c:forEach>
              </table>

css:

   table.data_table
{
    border: 2px gray solid;
}
table.data_table td,
table.data_table th,
table.data_table th.header2
{
    font-size: 7.5pt;
    white-space: normal;
    padding-left: 4px;
    padding-right: 4px;
}
.data_table {table-layout: fixed; }

尝试添加"table layout:fixed"作为表的CSS的一部分。也许这会解决你的问题。

也许你的身高有问题,因为你没有正确定义:

<td class="narrow" style="width:75px;height:75;">

把像素放成这样:

<td class="narrow" style="width:75px;height:75px;">

最新更新