<img src="http://files.jb51.net/file_images/article/201304/2013426162301523.png?2013326162439" alt=""><br><br><div class="msgheader"> <div class="right"><span style="CURSOR: pointer" onclick="copycode(getid('phpcode105'));"><u>코드 복사</u></span></div>코드는 다음과 같습니다</div> <div class="msgborder" id="phpcode105"> <br><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <br><html xmlns="http://www.w3.org/1999/xhtml"> <br><head> <br><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <br><title>固定标题列、标题头table</title> <br><style> <br>table{border-collapse:collapse;border-spacing:0px; width:100%; border:#000 solid 0px;} <br>table td{border:1px solid #000;height:25px; text-align:center; border-left:0px;} <br>table th{ background:#edd3d4; color:#a10333; border:#000 solid 1px; white-space:nowrap; height:21px; border-top:0px;border-left:0px;} <br>.t_left{width:30%; height:auto; float:left;border-top:1px solid #000;border-left:1px solid #000;} <br>/*t_r_content和cl_freeze高度相差20px, 高度为外观显示高度,可根据情况调整*/ <br>.t_r_content{width:100%; height:220px; background:#fff; overflow:auto;} <br>.cl_freeze{height:200px;overflow:hidden; width:100%;} <br>/* width 调整左边标题列宽度(左侧外观显示宽度); 指定为width:auto 在Opera下显示有问题; height比 t_r_content 高度小20px*/ <br>/* width 宽度为 右侧外观显示宽度 实际显示宽度大小为“t_r”宽度加上“cl_freeze”宽度 */ <br>/* 如果显示不正常,调整 t_r的width 使其和t_left的width之和小于100%;等于100%时会有问题*/ <br>.t_r{width:69.5%; height:auto; float:left;border-top:1px solid #000; border-right:#000 solid 1px;} <br>.t_r table{width:1700px;} <br>.t_r_title{width:1720px;}/*宽度比 t_r table 大20px (至少大20,小了滚动条滑到右侧显示有问题)*/ <br>.t_r_t{width:100%; overflow:hidden;} <br>.bordertop{ border-top:0px;} <br></style> <br><script> <br>function aa(){ <br>var a=document.getElementById("t_r_content").scrollTop; <br>var b=document.getElementById("t_r_content").scrollLeft; <br>document.getElementById("cl_freeze").scrollTop=a; <br>document.getElementById("t_r_t").scrollLeft=b; <br>} <br></script> <br></head> <br><body> <br><div style="width:100%"> <br><div class="t_left"> <br><div style="width:100%;"> <br><table> <br><tr> <br><th style="width:40%">账号</th> <br><th style="width:60%">姓名</th> <br></tr> <br></table> <br></div> <br><div class="cl_freeze" id="cl_freeze"> <br><table> <br><tr> <br><td style="width:40%" class="bordertop">1</td> <br><td style="width:60%" class="bordertop">1</td> <br></tr> <br><tr> <br><td>2</td> <br><td>2</td> <br></tr> <br><tr> <br><td>3</td> <br><td>3</td> <br></tr> <br><tr> <br><td>4</td> <br><td>4</td> <br></tr> <br><tr> <br><td>5</td> <br><td>5</td> <br></tr> <br><tr> <br><td>6</td> <br><td>6</td> <br></tr> <br><tr> <br><td>7</td> <br><td>7</td> <br></tr> <br><tr> <br><td>8</td> <br><td>8</td> <br></tr> <br><tr> <br><td>9</td> <br><td>9</td> <br></tr> <br><tr> <br><td>10</td> <br><td>10</td> <br></tr> <br><tr> <br><td>11</td> <br><td>11</td> <br></tr> <br><tr> <br><td>12</td> <br><td>12</td> <br></tr> <br><tr> <br><td>13</td> <br><td>13</td> <br></tr> <br><tr> <br><td>14</td> <br><td>14</td> <br></tr> <br><tr> <br><td>15</td> <br><td>15</td> <br></tr> <br><tr> <br><td>16</td> <br><td>16</td> <br></tr> <br><tr> <br><td>17</td> <br><td>17</td> <br></tr> <br><tr> <br><td>18</td> <br><td>18</td> <br></tr> <br><tr> <br><td>19</td> <br><td>19</td> <br></tr> <br><tr> <br><td>20</td> <br><td>20</td> <br></tr> <br></table> <br></div> <br></div> <br><div class="t_r"> <br><div class="t_r_t" id="t_r_t"> <br><div class="t_r_title"> <br><table> <br><tr> <br><th width="10%">字段A</th> <br><th width="20%">字段B</th> <br><th width="10%">字段C</th> <br><th width="20%">字段D</th> <br><th width="20%">字段E</th> <br><th width="20%">字段F</th> <br></tr> <br></table> <br></div> <br></div> <br><div class="t_r_content" id="t_r_content" onscroll="aa()"> <br><테이블> <br><tr> <br><td width="10%" class="bordertop">1</td> <br><td width="20%" class="bordertop">1</td> <br><td width="10%" class="bordertop">1</td> <br><td width="20%" class="bordertop">1</td> <br><td width="20%" class="bordertop">1</td> <br><td width="20%" class="bordertop">1</td> <br></tr> <br><tr> <br><td>2</td> <br><td>2</td> <br><td>2</td> <br><td>2</td> <br><td>2</td> <br><td>2</td> <br></tr> <br><tr> <br><td>3</td> <br><td>3</td> <br><td>3</td> <br><td>3</td> <br><td>3</td> <br><td>3</td> <br></tr> <br><tr> <br><td>4</td> <br><td>4</td> <br><td>4</td> <br><td>4</td> <br><td>4</td> <br><td>4</td> <br></tr> <br><tr> <br><td>5</td> <br><td>5</td> <br><td>5</td> <br><td>5</td> <br><td>5</td> <br><td>5</td> <br></tr> <br><tr> <br><td>6</td> <br><td>6</td> <br><td>6</td> <br><td>6</td> <br><td>6</td> <br><td>6</td> <br></tr> <br><tr> <br><td>7</td> <br><td>7</td> <br><td>7</td> <br><td>7</td> <br><td>7</td> <br><td>7</td> <br></tr> <br><tr> <br><td>8</td> <br><td>8</td> <br><td>8</td> <br><td>8</td> <br><td>8</td> <br><td>8</td> <br></tr> <br><tr> <br><td>9</td> <br><td>9</td> <br><td>9</td> <br><td>9</td> <br><td>9</td> <br><td>9</td> <br></tr> <br><tr> <br><td>10</td> <br><td>10</td> <br><td>10</td> <br><td>10</td> <br><td>10</td> <br><td>10</td> <br></tr> <br><tr> <br><td>11</td> <br><td>11</td> <br><td>11</td> <br><td>11</td> <br><td>11</td> <br><td>11</td> <br></tr> <br><tr> <br><td>12</td> <br><td>12</td> <br><td>12</td> <br><td>12</td> <br><td>12</td> <br><td>12</td> <br></tr> <br><tr> <br><td>13</td> <br><td>13</td> <br><td>13</td> <br><td>13</td> <br><td>13</td> <br><td>13</td> <br></tr> <br><tr> <br><td>14</td> <br><td>14</td> <br><td>14</td> <br><td>14</td> <br><td>14</td> <br><td>14</td> <br></tr> <br><tr> <br><td>15</td> <br><td>15</td> <br><td>15</td> <br><td>15</td> <br><td>15</td> <br><td>15</td> <br></tr> <br><tr> <br><td>16</td> <br><td>16</td> <br><td>16</td> <br><td>16</td> <br><td>16</td> <br><td>16</td> <br></tr> <br><tr> <br><td>17</td> <br><td>17</td> <br><td>17</td> <br><td>17</td> <br><td>17</td> <br><td>17</td> <br></tr> <br><tr> <br><td>18</td> <br><td>18</td> <br><td>18</td> <br><td>18</td> <br><td>18</td> <br><td>18</td> <br></tr> <br><tr> <br><td>19</td> <br><td>19</td> <br><td>19</td> <br><td>19</td> <br><td>19</td> <br><td>19</td> <br></tr> <br><tr> <br><td>20</td> <br><td>20</td> <br><td>20</td> <br><td>20</td> <br><td>20</td> <br><td>20</td> <br></tr> <br></테이블> <br></div> <br></div> </div> <br></body> <br></html> <br> </div>