2012-03-13 38 views
0

我想獲得一個GridView CSS解決方案,讓固定標題能夠工作,但唯一能讓標題行與其他列對齊的唯一方法是使用position:relative,但隨後打破了我試圖實現的固定標題。最重要的調整看起來非常糟糕,標題的「單元格」似乎全部融合在一起。GridView固定標題CSS對齊

我的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

+0

嗨,如果您嘗試使用此css方法,會出現很多問題。我正在使用第三方gridview控件。它只是asp.net網格視圖的擴展。 http://ideasparks.codeplex.com/ – Rohith 2013-05-29 10:07:25

回答

0

你能夠來包裝你的頭在具有位置的另一DIV:絕對的;在上面,然後使用工作位置:相對; CSS讓它與你的其他內容保持一致?

如果不能看到對齊問題,很難說。

+0

我添加了圖像。正如你所看到的,頂部的位置是關閉的,並且標題行被一起擦亮,並且不考慮單元格間距。 – Andrew 2012-03-13 20:14:01