私はからつかんだ、それ以下のコードについて質問があります:私は低レベルのプログラマの多くの午前は、ブラウザの高さを取得する方法を
http://jsfiddle.net/SAFX/Mq52k/16/
をので、私はちょうど十分なHTML/CSSを知っています取得する。私は150pxの固定値ではなく、ブラウザのウィンドウの高さに基づいてテーブルの高さを設定する方法を解明しようとしています。私の限られたCSSの知識で、私はこれがcssだけでは不可能かもしれないと仮定していますか? Javaスクリプトのようなものは必要でしょうか?
HTML:
<div class="panel panel-default">
<table class="table table-condensed" >
<thead>
<tr>
<th>Col1</th>
<th>Col2</th>
<th>Col3</th>
</tr>
</thead>
</table>
<div class="div-table-content">
<table class="table table-condensed">
<tbody>
<tr>
<td>data</td>
<td>more data</td>
<td>hello world, nice to see you again, and what a beautiful fixed header
column you have</td>
</tr>
<tr>
<td >data</td>
<td >more data</td>
<td >hello world, nice to see you again, and what a beautiful fixed header
column you have</td>
</tr>
<tr>
<td >data</td>
<td >more data</td>
<td >hello world, nice to see you again, and what a beautiful fixed header
column you have</td>
</tr>
<tr>
<td >data</td>
<td >more data</td>
<td >hello world, nice to see you again, and what a beautiful fixed header
column you have</td>
</tr>
<tr>
<td >data</td>
<td >more data</td>
<td >hello world, nice to see you again, and what a beautiful fixed header
column you have</td>
</tr>
<tr>
<td >data</td>
<td >more data</td>
<td >hello world, nice to see you again, and what a beautiful fixed header
column you have</td>
</tr>
</tbody>
</table>
</div>
CSS:
table {
table-layout:fixed;
}
.div-table-content {
height:150px;
overflow-y:auto;
}
。ビューポートの高さについては、100vhを使用できます(ビューポートの高さの100%を意味します)。 – Terry
私はTerryに同意し、CSSがスタイリングを処理できるようにします。これとjavascriptの必要はありません。 – jmag
甘く、素敵でシンプル。 – Dick