我有一個關於下面,我抓起從代碼的一個問題:如何獲取瀏覽器的高度
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;
}
即絕對有可能與支持視口單元(即那些支持CSS3規格)的瀏覽器。對於視口的高度,你可以用'100vh'(指視口高度的100%)。 – Terry
我同意特里,讓CSS處理樣式。這個不需要JavaScript。 – jmag
甜美,好看又簡單。把它作爲贏得的答案 – Dick