2016-12-16 21 views
0

我有如下所示的Css gridview。我试着在它上面悬停。但它不工作我一定行mouseover悬停在Gridview ASP.net使用CSS不工作

<style type="text/css"> 
     .gridview 
     { 
      font-family: "arial"; 
      background-color: #FFFFFF; 
      width: 100%; 
      font-size: small; 
     } 
     .gridview th 
     { 
      background: #7AC142; 
      padding: 5px; 
      font-size: small; 
     } 
     .gridview th a 
     { 
      color: #003300; 
      text-decoration: none; 
     } 
     .gridview td 
     { 
      background: #D9EDC9; 
      color: #333333; 
      font: small "arial"; 
      padding: 4px; 
     } 
     .gridview tr.even td 
     { 
      background: #FFFFFF; 
     } 
     .rows 
     { 
      background-color: #fff; 
      font-family: Arial; 
      font-size: 14px; 
      color: #000; 
      min-height: 25px; 
      text-align: left; 
      border: none 0px transparent; 
     } 
     .rows:hover td 
     { 
      background-color: #ff8000; 
      font-family: Arial; 
      color: #fff; 
      text-align: left; 
     } 
     .selectedrow 
     { 
      background-color: #ff8000; 
      font-family: Arial; 
      color: #fff; 
      font-weight: bold; 
      text-align: left; 
     } 
     .gridview td a:hover 
     { 
      background-color: #ff8000; 
      font-family: Arial; 
      color: #fff; 
      text-align: left; 
     } 
    </style> 

而下面是我的GridView

<asp:GridView ID="gvAsset" RowStyle-CssClass="rows" CssClass="gridview" AlternatingRowStyle-CssClass="even" 
    runat="server" OnRowCommand="gvAsset_RowCommand" EmptyDataText="No Record Available" 
    AutoGenerateColumns="False" AllowSorting="True" AllowPaging="False" DataKeyNames="Asset_ID" 
    Width="100%" OnSorting="gvAsset_Sorting" OnRowDataBound="gvAsset_RowDataBound"> 
    <RowStyle /> 
    <AlternatingRowStyle /> 
    <HeaderStyle /> 
    <Columns> 
     <asp:TemplateField> 
      <ItemTemplate> 
       <asp:UpdatePanel ID="updPanel2" runat="server"> 
        <ContentTemplate> 
         <asp:LinkButton ID="lnkEdit" CommandName="EditRow" CommandArgument='<%# Eval("Asset_ID") %>' 
          runat="server">Edit</asp:LinkButton> 
        </ContentTemplate> 
       </asp:UpdatePanel> 
      </ItemTemplate> 
     </asp:TemplateField> 
     <asp:BoundField ReadOnly="True" DataField="Asset_ID" SortExpression="Asset_ID" HeaderText="ID"></asp:BoundField> 
    </Columns> 
    <PagerStyle HorizontalAlign="Center"></PagerStyle> 
</asp:GridView> 

我的CSS悬停工作在第一行,但不是第二排。然后第三行正在工作,但不是第四行,依此类推。 (它不工作在偶数行)我不擅长CSS我尝试已经将悬停或td从一行css代码更改为另一行css代码,但它仍然无法工作。

回答

0

改变你的背景后.rows:hover td

.rows:hover td, .even:hover td 
{ 
    background-color: #ff8000 !important; 
    font-family: Arial; 
    color: #fff; 
    text-align: left; 
} 

!important颜色是nessecary因为你设置.gridview tr.even td白色背景。

+0

非常感谢你.. –