我有一个比我的aspx页面更宽的gridview,所以我需要gridview的标题与水平滚动条一起滚动,但仍然与垂直滚动条一起修复,我如何这是什么成绩?请帮忙?经过大量的谷歌搜索之后,我在将网格放置在一个div窗格中之后,尝试了各种CSS类,但是这会同时锁定标题和水平和垂直两种方式。请帮助我只修复垂直滚动页眉。我的aspx页面的只在垂直滚动条上冻结gridview标题
部分
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true">
<ContentTemplate>
<div runat="server" id="GridViewDiv" style="overflow:auto" >
<asp:HiddenField ID="BindOnPostBack" Value="1" runat="server" />
<asp:GridView Width="100%" ID="ProjectsGridView" runat="server" AutoGenerateColumns="false"
OnRowCreated="BudgetGridView_RowCreated" OnRowDataBound="BudgetGridView_RowDataBound" PagerSettings-Visible="true" PageSize="20"
AllowPaging="true" AllowSorting="true" RowStyle-BackColor="#E8EAF7" RowStyle-BorderColor="White"
RowStyle-Height="19px" RowStyle-Font-Size="11px" RowStyle-HorizontalAlign="Left"
RowStyle-VerticalAlign="Middle" RowStyle-Font-Names="Tahoma,Helvetica,Arial"
HeaderStyle-BackColor="#d1d5ef" HeaderStyle-Height="22px" HeaderStyle-HorizontalAlign="Left"
HeaderStyle-Font-Names="Tahoma,Helvetica,Arial" HeaderStyle-Font-Size="13px"
HeaderStyle-Wrap="false" HeaderStyle-Font-Underline="false" RowStyle-Wrap="false"
PagerSettings-Position="Top" DataKeyNames="ID">
and my css for this:
div#GridViewDiv {
width: expression(document.getElementById("ctl00_contentPanel").style.width);
height: expression(document.getElementById("contentdiv").style.width);
overflow: scroll;
position: relative;
}
div#GridViewDiv th {
top: expression(document.getElementById("GridViewDiv").scrollTop - 2);
left: expression(parentNode.parentNode.parentNode.parentNode.scrollLeft);
position: relative;
z-index: 50;
}
td.locked, th.locked {
position:relative;
left:expression((this.parentElement.parentElement.parentElement.parentElement.scrollLeft-2)+'px');
}
你可以显示你的HTML和CSS? – bot
感谢您停止机器人。我已经添加了相关代码,对此的任何帮助都会很棒! – Viniez