首页 新闻 会员 周边 捐助

表头固定为什么对不齐?

0
悬赏园豆:50 [已解决问题] 解决于 2013-07-27 10:09

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="javascript">
    function SYNC_Roll(obj) {
        titlediv.style.posLeft = -obj.scrollLeft;
    }  
</script>
<style type="text/css">
body{font-family:宋体;font-size:12px; margin: 0px;padding: 0px;background-color: #ffffff;overflow: auto;background-color: #ffffff;scrollbar-face-color: #ccc;scrollbar-highlight-color: #fafafa;scrollbar-shadow-color: #555;scrollbar-3dlight-color: #ffffff;scrollbar-arrow-color: #777777;scrollbar-track-color: #fcfcfc;scrollbar-darkshadow-color: #ffffff;}
.reporttable{border:1px solid #000000; border-collapse:collapse;font-size:12px;}
.small{ font-size:12px;font-family:宋体;}
hr{height: 1px;border: 0;border-top: 1px dashed #CCCCCC;}
.report_title{font-family:宋体;font-size:16.5px;font-weight:bolder;}
a{color:#240589;text-decoration: none;}
.btnQuery{width:0px;height:10px;}
.griddiv{overflow-x:hidden;border:black 1px solid;background: #f8f9fc;}
.title {border-right: #555 1px solid;border-top: #fff 1px solid;border-bottom: #555 1px solid;border-left: #fff 1px solid;padding:2 2 2 2;background: #ccc;cursor: hand;font-size:12px;overflow:hidden;white-space: nowrap;text-align:center}
.desc {BORDER-RIGHT: #555 1px solid;BORDER-TOP: #fff 1px solid;BORDER-BOTTOM: #555 1px solid;BORDER-LEFT: #fff 1px solid;padding:2 1 2 2;CURSOR: hand;font-Size:9pt;overflow:hidden;WHITE-SPACE: nowrap;background:#ccc url(/images/desc.gif) 1px center no-repeat;text-align:center}
.asc {BORDER-RIGHT: #555 1px solid;BORDER-TOP: #fff 1px solid;BORDER-BOTTOM: #555 1px solid;BORDER-LEFT: #fff 1px solid;padding:2 1 2 2;CURSOR: hand;font-Size:9pt;overflow:hidden;WHITE-SPACE: nowrap;background:#ccc url(/images/asc.gif) 1px  center no-repeat;text-align:center}
#tbreport td{white-space: nowrap;border-right: #ddd 1px solid;border-top: #ddd 1px solid;font-size:12px;}
#tbreport .treport{font-size:12px;font-family:宋体;}
</style>
</head>

<body>
<div class='griddiv' id='griddiv'>
<div id="titlediv" style="position:relative;"></div>
<div id="tablediv" style="overflow:auto;" onscroll="SYNC_Roll(this)">
<table id="tbreport"  TSorter="true" border="0px" cellpadding="3px" cellspacing="0px" width="100%" class="treport">
<thead style="display:table-header-group;">
<tr id="titletr">
<td align="center" nowrap="nowrap">医生姓名</td>
<td TDataType="float" align="center" nowrap="nowrap">西药费</td>
<td TDataType="float" align="center" nowrap="nowrap">草药费</td>
<td TDataType="float" align="center" nowrap="nowrap">材料费</td>
<td TDataType="float" align="center" nowrap="nowrap">治疗费</td>
<td TDataType="float" align="center" nowrap="nowrap">注射费</td>
<td TDataType="float" align="center" nowrap="nowrap">光疗费</td>
<td TDataType="float" align="center" nowrap="nowrap">水疗费</td>
<td TDataType="float" align="center" nowrap="nowrap">检查费</td>
<td TDataType="float" align="center" nowrap="nowrap">化验费</td>
<td TDataType="float" align="center" nowrap="nowrap">手术费</td>
<td TDataType="float" width="60px" align="center">合计</td>
</tr>
</thead>
<tbody>
<tr class="RepeaterLine1">
<td>李健</td>
<td align="right">314.46</td>
<td align="right">32.24</td>
<td align="right">1</td>
<td align="right">248</td>
<td align="right">276</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">350</td>
<td align="right">10</td>
<td align="right">&nbsp;</td>
<td align="right">1231.7</td>
</tr>
<tr class="RepeaterLine1">
<td>相勇</td>
<td align="right">26728.47</td>
<td align="right">5145.3</td>
<td align="right">6</td>
<td align="right">6390</td>
<td align="right">2439</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">3910</td>
<td align="right">2138</td>
<td align="right">&nbsp;</td>
<td align="right">46756.77</td>
</tr>
<tr class="RepeaterLine1">
<td>闫毅</td>
<td align="right">78337.6</td>
<td align="right">13861.4</td>
<td align="right">9</td>
<td align="right">4440</td>
<td align="right">10898</td>
<td align="right">1160</td>
<td align="right">&nbsp;</td>
<td align="right">16560</td>
<td align="right">5533</td>
<td align="right">160</td>
<td align="right">130959</td>
</tr>
<tr class="RepeaterLine1">
<td>赵赣琪</td>
<td align="right">34094.58</td>
<td align="right">5400.3</td>
<td align="right">14.3</td>
<td align="right">1660</td>
<td align="right">3494</td>
<td align="right">260</td>
<td align="right">210</td>
<td align="right">12580</td>
<td align="right">3160</td>
<td align="right">180</td>
<td align="right">61053.18</td>
</tr>
<tr class="RepeaterLine1">
<td>曾衍胜</td>
<td align="right">47816.65</td>
<td align="right">7216.31</td>
<td align="right">16</td>
<td align="right">5531</td>
<td align="right">4504</td>
<td align="right">100</td>
<td align="right">1890</td>
<td align="right">9300</td>
<td align="right">3541</td>
<td align="right">560</td>
<td align="right">80474.97</td>
</tr>
<tr class="RepeaterLine1">
<td>卢建华</td>
<td align="right">37415.27</td>
<td align="right">474.4</td>
<td align="right">&nbsp;</td>
<td align="right">2523</td>
<td align="right">4188</td>
<td align="right">180</td>
<td align="right">&nbsp;</td>
<td align="right">9330</td>
<td align="right">965</td>
<td align="right">610</td>
<td align="right">55685.67</td>
</tr>
<tr class="RepeaterLine1">
<td>陈婷</td>
<td align="right">6055.64</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">440</td>
<td align="right">180</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">18</td>
<td align="right">373</td>
<td align="right">130</td>
<td align="right">7196.64</td>
</tr>
<tr class="RepeaterLine1">
<td>陈体高</td>
<td align="right">975.7</td>
<td align="right">41.7</td>
<td align="right">&nbsp;</td>
<td align="right">340</td>
<td align="right">13</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">1370.4</td>
</tr>
<tr class="RepeaterLine1">
<td>宋燕飞</td>
<td align="right">1626.2</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">180</td>
<td align="right">75</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">1881.2</td>
</tr>
<tr class="RepeaterLine1">
<td>曾伟华</td>
<td align="right">6257.17</td>
<td align="right">&nbsp;</td>
<td align="right">0.5</td>
<td align="right">&nbsp;</td>
<td align="right">272</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">350</td>
<td align="right">314</td>
<td align="right">&nbsp;</td>
<td align="right">7193.67</td>
</tr>
<tr class="RepeaterLine1">
<td>曾祥康</td>
<td align="right">3705.33</td>
<td align="right">160.6</td>
<td align="right">22</td>
<td align="right">9148</td>
<td align="right">180</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">180</td>
<td align="right">94</td>
<td align="right">1080</td>
<td align="right">14569.93</td>
</tr>
<tr class="RepeaterLine1">
<td>刘燕</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">5038</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">5038</td>
</tr>
<tr class="RepeaterLine1">
<td>廖秀</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">1126</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">1126</td>
</tr>
<tr class="RepeaterLine1">
<td>钟瑞平(性病科)</td>
<td align="right">21227.14</td>
<td align="right">&nbsp;</td>
<td align="right">7</td>
<td align="right">1728</td>
<td align="right">988</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">1080</td>
<td align="right">1198</td>
<td align="right">&nbsp;</td>
<td align="right">26228.14</td>
</tr>
<tr class="RepeaterLine1">
<td>张国基</td>
<td align="right">39939.25</td>
<td align="right">77.5</td>
<td align="right">43.8</td>
<td align="right">506</td>
<td align="right">1569</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">3322</td>
<td align="right">3401</td>
<td align="right">&nbsp;</td>
<td align="right">48858.55</td>
</tr>
<tr class="RepeaterLine1">
<td>蔡莉</td>
<td align="right">25999.6</td>
<td align="right">27.8</td>
<td align="right">19.5</td>
<td align="right">1080</td>
<td align="right">1706</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">1467</td>
<td align="right">2413</td>
<td align="right">&nbsp;</td>
<td align="right">32712.9</td>
</tr>
<tr class="RepeaterLine1">
<td>古素芬</td>
<td align="right">12568.26</td>
<td align="right">48.8</td>
<td align="right">0.6</td>
<td align="right">920</td>
<td align="right">782</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">1408</td>
<td align="right">1918</td>
<td align="right">275</td>
<td align="right">17920.66</td>
</tr>
<tr class="RepeaterLine1">
<td>杨伟丽</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">35</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">35</td>
</tr>
<tr class="RepeaterLine1">
<td>陆建平</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">30</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">30</td>
</tr>
<tr class="RepeaterLine1">
<td>杜洁妮</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">398</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">398</td>
</tr>
<tr class="RepeaterLine1">
<td>刘苏红</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">168</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">168</td>
</tr>
<tr class="RepeaterLine1">
<td>钟瑞平(皮肤科)</td>
<td align="right">16592.13</td>
<td align="right">1902.9</td>
<td align="right">13.9</td>
<td align="right">1590</td>
<td align="right">872</td>
<td align="right">150</td>
<td align="right">120</td>
<td align="right">3060</td>
<td align="right">687</td>
<td align="right">50</td>
<td align="right">25037.93</td>
</tr>
</tbody>
<tr class="RepeaterLine1">
<td align="center">合计</td>
<td align="right">359653.44</td>
<td align="right">34389.26</td>
<td align="right">153.6</td>
<td align="right">43519</td>
<td align="right">32436</td>
<td align="right">1850</td>
<td align="right">2220</td>
<td align="right">62915</td>
<td align="right">25745</td>
<td align="right">3045</td>
<td align="right">565926.29</td>
</tr>
 
</table>
<table align="center" class="small" width="100%">
 <tr><td>打印时间:2011-05-28 07:42</td></tr>
</table>

  </div>
</div>
</body>
</html>
<script language="javascript">
    function createtitle(ttbdiv, tdiv, ttb, ttr) {
     tdiv.style.width = ttb.offsetWidth;
  var tHeadHeight = document.all["titletr"].offsetHeight;
  ttb.style.marginTop = -tHeadHeight; 
        var newtit="", sDataType = "", sSort = "", tSort = "false", sCursor = "";
  var i_width=0; 
        if (typeof (ttb.TSorter) != "undefined") tSort = ttb.TSorter;
        newtit = "<table border='0' cellpadding='0' cellspacing='0'><tr>";
        for (i = 0; i < titletr.cells.length; i++) {
            ttd = titletr.cells[i];
            if (tSort == "true") {
                sDataType = (typeof (ttd.TDataType) == "undefined" ? "" : ttd.TDataType);
                if (sDataType == "nosort") {
                    sSort = " ";
                    sCursor = "defalut";
                }
                else {
                    sSort = " onclick=\"sortTable('tbreport'," + String(i) + (sDataType == "" ? "" : (",'" + sDataType + "'")) + ")\" ";
                    sCursor = "hand";
                }
            }
            newtit = newtit + "<td><span id='TSPAN_" + String(i) + "' class='title'" + sSort + "style='width:" + (ttd.clientWidth + 1) + "px;cursor:" + sCursor + "'>" + ttd.innerText + "</span></td>";
   i_width+=ttb.rows[0].cells[i].clientWidth+1;
        }
        newtit = newtit + "</tr></table>";
  tdiv.innerHTML = newtit;
        //ttr.style.visibility = "hidden";
        //if (ttr.rowIndex != ttb.rows.length - 1)
        //    ttb.moveRow(ttr.rowIndex, ttb.rows.length - 1); 
  //ttb.style.pixelWidth = i_width;
  //alert(i_width+"|"+ttb.offsetWidth);  
  //alert(newtit);
  //alert(ttbdiv.scrollLeft+"|"+ttbdiv.scrollWidth+"|"+ttbdiv.offsetWidth);

  var tt1=tdiv.getElementsByTagName("TABLE")[0];
        var ttr1=tt1.rows[0];
  i_width=0;
  for (i = 0; i < ttr1.cells.length; i++) {
   ttd = ttr1.cells[i];
   //ttd.getElementsByTagName("span")[0].style.pixelWidth=ttb.rows[0].cells[i].clientWidth + 1;
   i_width+=ttb.rows[0].cells[i].clientWidth + 1;
   //alert(ttd.getElementsByTagName("span")[0].offsetWidth+"|"+titletr.cells[i].offsetWidth);
  }
  var w_gap = i_width - ttb.clientWidth;
  if(w_gap != 0)
  {
   //ttb.style.width = tt1.clientWidth;
   //gdiv.style.pixelWidth=gdiv.offsetWidth+w_gap;
  }
  //tdiv.style.width = i_width + w_gap;
  //ttb.style.pixelWidth=i_width;
  //alert(newtit);
  //alert(ttbdiv.offsetWidth+"|"+ttb.clientWidth); 
    }
    function SYNC_Roll(obj) {
        titlediv.style.posLeft = -obj.scrollLeft;
    }
    function SetGrid(awidth, aheight) {
        var gdiv = document.getElementById("griddiv");
        titdiv = document.getElementById("titlediv");
        ttbdiv = document.getElementById("tablediv");
        ttb = document.getElementById("tbreport");
        ttr = document.getElementById("titletr");
        if (!isSpace(gdiv) && !isSpace(titdiv) && !isSpace(ttbdiv) && !isSpace(ttbdiv)) {
            gdiv.style.pixelWidth = awidth;
            tablediv.style.pixelWidth = awidth;
            tablediv.style.pixelHeight = aheight;
   //ttb.style.pixelWidth=ttb.clientWidth;
            createtitle(ttbdiv,titdiv, ttb, ttr);
        }
    }
    function setTableGrid() {
        var v_width, v_heigt;
        v_width = 924;
        v_heigt = 300;
  //alert(v_width+"|"+v_heigt);
        SetGrid(v_width, v_heigt);
    } 
function isSpace(strMain)
{
 var strComp = strMain;
 try
 {
  if (strComp==" " || strComp=="" || strComp==" " || strComp==null || strComp=="null" || strComp=="0" || strComp.length==0 || typeof strMain == "undefined" || strMain == "undefined" )
  {
  return true;
  }
  else
  {
   return false;
  }
 }
 catch(e)
 {
  return false;
 }
}  
</script>
<script language="javascript">
setTableGrid();
/*var s_width=0;
for (i = 0; i < titletr.cells.length; i++) {
 ttd = titletr.cells[i];
 s_width+=ttd.clientWidth+1;
}
var w_gap = s_width - tbreport.clientWidth;
alert(s_width+"|"+tbreport.clientWidth);
alert(w_gap);
tbreport.style.width=s_width+w_gap;
titlediv.style.width=s_width+w_gap;*/
//alert(s_width);
</script>

sgm的主页 sgm | 初学一级 | 园豆:57
提问于:2011-05-30 11:45
< >
分享
最佳答案
0

我试了一下,使用不同的浏览器打开效果是不一样的!可能是你是用的一些样式只能被一种浏览器内核解析(各种浏览器内核网页编写语法的解释是不同的!)

收获园豆:50
suber | 菜鸟二级 |园豆:260 | 2011-06-01 10:32
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册