<style>
.Freezing
{
position:relative ;
table-layout:fixed;
top:expression(this.offsetParent.scrollTop);
z-index: 10;
}
.Freezing th{text-overflow:ellipsis;overflow:hidden;white-space: nowrap;padding:2px;}
</style> <body style="font-size=12px">
<form id="form1" runat="server">
<div style="overflow-y: scroll; height: 200px;width:300px" id="dvBody">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="3" OnRowDeleting="GridView1_RowDeleting" OnRowEditing="GridView1_RowEditing"
OnRowUpdating="GridView1_RowUpdating" OnRowCancelingEdit="GridView1_RowCancelingEdit" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" Font-Size="12px" OnRowCreated="GridView1_RowCreated" >
<asp:BoundField DataField="姓名" HeaderText="姓名" />
<HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" CssClass="Freezing"/>
</asp:GridView>
</div>
</form>
</body>
<HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" CssClass="Freezing"/>
HeaderStyle 中加入 CssClass="Freezing" 没有作用怎么办??
还有一个问题, div 有滚动条时,点击gridview 里面一行数据,滚动条会自动回到顶部是怎么回事?
.Freezing
{
position:relative ;
table-layout:fixed;
top:expression(this.offsetParent.scrollTop);
z-index: 10;
}
.Freezing th{text-overflow:ellipsis;overflow:hidden;white-space: nowrap;padding:2px;}
</style> <body style="font-size=12px">
<form id="form1" runat="server">
<div style="overflow-y: scroll; height: 200px;width:300px" id="dvBody">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="3" OnRowDeleting="GridView1_RowDeleting" OnRowEditing="GridView1_RowEditing"
OnRowUpdating="GridView1_RowUpdating" OnRowCancelingEdit="GridView1_RowCancelingEdit" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" Font-Size="12px" OnRowCreated="GridView1_RowCreated" >
<asp:BoundField DataField="姓名" HeaderText="姓名" />
<HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" CssClass="Freezing"/>
</asp:GridView>
</div>
</form>
</body>
<HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" CssClass="Freezing"/>
HeaderStyle 中加入 CssClass="Freezing" 没有作用怎么办??
还有一个问题, div 有滚动条时,点击gridview 里面一行数据,滚动条会自动回到顶部是怎么回事?
<style type="text/css">
.fixedHeader{
POSITION: relative; TOP: expression(this.offsetParent.scrollTop); }
.fixcol{z-index:999; position: relative; left: expression(this.offsetParent.scrollLeft);}
.fixCol{ POSITION: relative; Left: expression(this.offsetParent.scrollLeft) }
</style><div style="overflow:auto; position:relative; width:333px; height: 205px">
<asp:GridView ID="GridView1" runat="server" Font-Size="12px" BackColor="#FFFFC0" GridLines="Both" CellPadding="4" Width="560" AllowPaging="True" OnRowDataBound="GridView1_RowDataBound" OnSelectedIndexChanging="GridView1_SelectedIndexChanging">
<HeaderStyle BackColor="Red" Height="26px" CssClass="fixedHeader" />
</asp:GridView>
</div>