GridView固定头CSS对齐

时间:2012-03-13 20:03:03

标签: asp.net css gridview

我正在尝试使用GridView CSS解决方案来使固定标头工作,但是我可以让标题行与其余列对齐的唯一方法是使用position:relative,但是这会打破我试图实现的固定标头。最高调整似乎并不严重,标题的“单元格”似乎全部融合在一起。

我的CSS:

.fixedHeader
{
   font-weight:bold;
   font-size:small;
   position:absolute;
   width:1070px;
   text-align:justify;
   background-color: #006699;
   color: #ffffff;
   height: 25px;
   expression(Sys.UI.DomElement.getBounds(document.getElementById("Panel3")).y-      25);
}

我的GridView:

<asp:Panel ID="Panel3" runat="server" Height="354px" ScrollBars="Vertical" 
        Width="1070px" Font-Size="Small" onscroll="$get('MainContent_hdnScrollTop').value = this.scrollTop;">

          <input type="hidden" id="hdnScrollTop" runat="server" value="0" />

        <asp:GridView ID="GridView1" runat="server"  
        AutoGenerateColumns="False" AllowSorting="True" CellPadding="4" 
        ForeColor="#333333" GridLines="None" 
        onrowdatabound="GridView1_RowDataBound">
                <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                <HeaderStyle CssClass="fixedHeader" />

The header smooshed

1 个答案:

答案 0 :(得分:0)

你能将你的标题包装在另一个有位置的DIV中:绝对;在它上面,然后使用工作位置:相对; CSS让它与你的其他内容保持一致?

很难说没有能够看到对齐问题是什么。

相关问题