将单元格大小设置为不超过某个宽度&高度

时间:2012-02-22 21:24:20

标签: html css

我最初硬编码了我的细胞宽度和高度。但我们反对这一点。现在我希望它按原样运行,缩小和扩展,但一旦达到一定的宽度就停止。

enter image description here

  <table align="center" class="data_extract vert_scroll_table" >
              <tr>

                  <c:forEach var="heading" items="${results.headings}"> 

                      <th class="data_extract">${heading}</th>

                  </c:forEach>
              </tr>
              <c:forEach var="row" items="${results.data}">
                  <tr>
                      <c:forEach var="cell" items="${row}" varStatus="rowStatus">
                          <td class="data_extract">
                              <c:choose>
                                    <c:when test="${results.types[rowStatus.index].array}">
                                    <c:set var="comma" value="," />
                                        <c:forEach var="elem" items="${cell}" varStatus="cellStatus">
                                            <c:set var="myVar" value="${cellStatus.first ? '' : myVar} ${elem} ${cellStatus.last ? '' : comma}" /> 
                                        </c:forEach>
                                        <span class="mouseover_text" title="${myVar}">${myVar}</span>
                                    </c:when>
                                  <c:otherwise>
                                        ${cell}
                                  </c:otherwise>
                              </c:choose>
                          </td>
                      </c:forEach>
                  </tr>
              </c:forEach>
              </table>

的CSS:

table.data_extract
{

 border: 2px gray solid;
 border-collapse: collapse;
 }

td.data_extract,
th.data_extract,
table.data_extract td,
 table.data_extract th

{

 text-align: center;
 font-size: 7.5pt;
 white-space: normal;


 }

2 个答案:

答案 0 :(得分:0)

答案 1 :(得分:0)

max-width: {whatever width you want}min-width: {whatever width you want}添加到您的td.data_extract规则中。