国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 開(kāi)發(fā) > CSS > 正文

css 固定表頭 拖動(dòng)滾動(dòng)條時(shí)對(duì)應(yīng)表頭所對(duì)應(yīng)的列 ie6測(cè)試通過(guò)

2024-07-11 08:35:41
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

項(xiàng)目中設(shè)計(jì)的報(bào)表table設(shè)計(jì)的列數(shù)相對(duì)過(guò)多,當(dāng)拖動(dòng)下方的滾動(dòng)條時(shí)無(wú)法對(duì)應(yīng)表頭所對(duì)應(yīng)的列,因此在網(wǎng)上搜索了好一段日子,最后在網(wǎng)上找到了一些參考資料,然后總結(jié)歸納出兼容行列合并的固定表頭demo。
多瀏覽器沒(méi)有做太多測(cè)試,在ie6中已測(cè)試通過(guò)。

功能期待了很久今天終于找到解決的方式,總結(jié)到j(luò)avaeye中方便日后查閱。實(shí)現(xiàn)方式可能還有更好的,希望有大牛路過(guò),給我留點(diǎn)更好的實(shí)現(xiàn)例子作日后交流之用。
以下是相關(guān)的css


<style type=”text/css”>
<!–
body,table, td, a {font:9pt;}
/*重點(diǎn):固定行頭樣式*/
.scrollRowThead{position: relative; left: expression(this.parentElement.parentElement.parentElement.parentElement.scrollLeft);z-index:0;}
/*重點(diǎn):固定表頭樣式*/
.scrollColThead {position: relative;top: expression(this.parentElement.parentElement.parentElement.scrollTop);z-index:2;}
/*行列交叉的地方*/
.scrollCR { z-index:3;}
/*div外框*/
.scrollDiv {height:200px;clear: both; border: 1px solid #EEEEEE;OVERFLOW: scroll;width: 320px; }
/*行頭居中*/
.scrollColThead td,.scrollColThead th{ text-align: center ;}
/*行頭列頭背景*/
.scrollRowThead,.scrollColThead td,.scrollColThead th{background-color:EEEEEE;}
/*表格的線*/
.scrolltable{border-bottom:1px solid #CCCCCC; border-right:1px solid #CCCCCC; }
/*單元格的線等*/
.scrolltable td,.scrollTable th{border-left: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; padding: 5px; }
.scrollTable thead th{background-color:#EEEEEE;font-weight:bold;position:relative;}
–>
</style>

以下是HTML


<h1>利用CSS代碼讓Table產(chǎn)生固定表頭</h1>
<div id=”scrollDiv” class=”scrollDiv” >
<table border=”0″ cellpadding=”3″ cellspacing=”0″ width=”500″ class=”scrollTable”>
<thead>
<tr class=”scrollColThead” >
<th class=”scrollRowThead scrollCR” >&nbsp;</th>
<th colspan=”2″>列頭</th>
<th colspan=”2″>列頭</th>
<th rowspan=”2″>列頭</th>
</tr>
<tr class=”scrollColThead” >
<th class=”scrollRowThead scrollCR” >h1</th>
<th >h2</th>
<th >h3</th>
<th >h4</th>
<th >h5</th>
</tr>
</thead>
<tr>
<td class=”scrollRowThead” >
<input type=”checkbox” name=”checkbox” value=”checkbox”>
a</td>
<td>單元格2</td>
<td>單元格3</td>
<td>單元格4</td>

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 锡林浩特市| 乐亭县| 马关县| 建阳市| 宁安市| 合山市| 鸡泽县| 公主岭市| 固原市| 抚州市| 射阳县| 昌平区| 五大连池市| 承德县| 信丰县| 海城市| 新邵县| 垣曲县| 巴马| 盘锦市| 鹰潭市| 蒙山县| 康平县| 泸西县| 浮山县| 卫辉市| 普安县| 阆中市| 旬邑县| 城步| 中江县| 白河县| 徐州市| 高尔夫| 延边| 双辽市| 大安市| 方正县| 淮北市| 柯坪县| 腾冲县|