1

2列のテーブルがあります。2 番目の列は常にその内容を完全に表示し、幅は内容に基づいて自動的に計算する必要があります。最初の列は、特定のポイント (最大幅) まで可能な限り広くする必要があります。残念ながら、HTMLではなくWPFにしか慣れていません。WPF では、次のように記述します。

<Grid.ColumnDefinitions>
   <ColumnDefinition Width="*" MaxWidth="600" />
   <ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>

私のHTMLは:

<colgroup>
   <col class="fullWidthCol" />
   <col class="autoWidthCol" />
</colgroup>

私のCSSは次のとおりです。

.fullWidthCol {
   width: 100%;
   max-width: 600px;
}

.autoWidthCol {
   overflow: auto;
}

私も近くにいないと確信しています。私の最大幅を無視し、最初の列のサイズをできるだけ大きくして、2番目の列を画面の右側に押し出しています。

4

1 に答える 1

0

仕様tdを受け入れていないようです。代わりにmax-width使用してください。widthtdwidth同じ効果があります。

例:

table
{ width: 100%; }

.fullWidthCol
{ width: 300px; }

<table border="1">
  <tr>
    <td class="fullWidthCol">The first column should be as wide as possible up to a certain point (max width). </td>
    <td class="autoWidthCol">The second column should ALWAYS show it's content perfectly and the width should be automatically calculated based on the content. </td>
  </tr>  
</table>

またはhttp://jsfiddle.net/HdSA2/を参照してください。

于 2012-10-23T16:10:46.650 に答える