曾经在项目中实现过一个固定表头的html表格,但使用了非常臃肿的代码,因为实际上是画了三个一样的表格。偶然的机会,发现了一个纯粹用html和css实现的固定表头的表格。现将其简化代码摘录如下。
原地址见: http://www.imaputz.com/cssstuff/bulletversion.html。
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head> |
|
table, td, a { |
|
.td |
|
div.tablecontainer { |
|
/* winie 6.x needs to re-account for it's scrollbar. give it some padding */ |
|
/* clean up for allowing display opera 5.x/6.x and macie 5.x */ |
|
/* reset overflow value to hidden for all non-ie browsers. */ |
|
/* define width of table. ie browsers only */ |
|
/* winie 6.x needs to re-account for padding. give it a negative margin */ |
|
/* define width of table. opera 5.x/6.x and macie 5.x */ |
|
/* define width of table. add 16px to width for scrollbar. */ |
|
/* set table header to a fixed position. winie 6.x only */
本文关键:推荐:用CSS实现的固定表头的HTML表格
|