固定表头问题
以下是一固定纵向和横向表头的代码:
<style type="text/css">
.fixedHeaderTr { POSITION: relative;z-index:0 ; TOP: expression(this.offsetParent.scrollTop); }
.Freezing { POSITION: relative; ; LEFT: expression(this.offsetParent.scrollLeft) }
.mainDiv { SCROLLBAR-FACE-COLOR: #9999ff; OVERFLOW: auto; ;
WIDTH: expression(document.body.clientWidth-20); ;HEIGHT: expression((document.body.clientHeight-this.offsetTop-20>this.children[0].offsetHeight)?(this.children[0].offsetHeight+20) : (document.body.clientHeight-this.offsetTop-20)) }
</style>
</head>
<body>
<form id="form1" runat="server" method="post">
<div class="mainDiv" style="width:800px;height:600px;overflow-x:auto;overflow-y:auto;">
<asp:GridView ID="GridView1" runat="server" BorderColor="#CC9966" BorderStyle="None" BorderWidth="1px"
BackColor="White" CellPadding="4" Height="150px" Width="677px">
<FooterStyle ForeColor="#330099" BackColor="#FFFFCC"></FooterStyle>
<HeaderStyle Font-Bold="True" ForeColor="#FFFFCC" BackColor="#990000" CssClass="fixedHeaderTr" ></HeaderStyle>
<PagerStyle HorizontalAlign="Center" ForeColor="#330099" BackColor="#FFFFCC"></PagerStyle>
<RowStyle VerticalAlign="middle" HorizontalAlign="center" />
<Columns>
<asp:BoundField DataField="CustomerID" HeaderText="ID" >
<ItemStyle BackColor="#990000" CssClass="Freezing" />
</asp:BoundField>
</Columns>
</asp:GridView>
</div>
<br />
</form>
</body>
但是当字段他多时,表头会很长,这样,表头就超出我所限定的区域,如何才能将表头也像正文一样限定在我所设置的区域内?