2016-07-21 23 views
0

我將最小寬度和最大寬度設置爲TH標籤。 Min-width屬性反映了max-width屬性未反映的位置。當我檢查,並檢查了個標籤它看起來只適用如何在表格中設置<th>標籤的最大寬度,最大寬度是否支持<th>?

<table> 
<thead> 
<tr> 
    <th> S.No </th> 
    <th> Name </th> 
    <th style="min-width:40px; max-width:150px;"> Description </th> 
    <th> Gender </th> 
</tr> 
</thead> 
<tbody> 
<tr> 
    <td> 1 </td> 
    <td> Xyz </td> 
    <td> Having Excess content more than 160 characters </td> 
    <td> Male/Female </t> 
</tr> 
</tbody> 
</table> 
+0

max-width在表中,可以應用於所有th標籤。不是任何個人。 – eronax59

+0

add'table {table-layout:fixed;}'和'th {max-width:150px}' – murli2308

回答

1
<table> 
    <thead> 
     <tr> 
      <th> S.No </th> 
      <th> Name </th> 
      <th style="width:150px; max-width: 150px;"> Description </th> 
      <th> Gender </th> 
     </tr> 
    </thead> 
    <tbody> 
     <tr> 
      <td> 1 </td> 
      <td> Xyz </td> 
      <td> Having Excess content more than 160 characters </td> 
      <td> Male/Female </td> 
     </tr> 
    </tbody> 
</table> 
+0

如果我直接給出width:150px;那麼沒有最小寬度的情況。 Feild總是佔用150Px; – suresh

+0

min-width:??我已經添加了最大寬度..作爲預防措施.. – Pranjal

+0

如果我有更少的內容然後??? – suresh

0

你可以在你的CSS下面使用th和td標籤

max-width: 150px; word-wrap:break-word;

但是我覺得只有width或最大寬度也應該工作。

+0

沒有運氣的傢伙...直到我用寬度它不反映。 。 – suresh

0

表列將根據數據增加

  1. 內嵌寬度行不通
  2. 什麼可以做,它把表格的佈局固定table(table-layout:fixed;)
  3. 然後指定寬度列