2013-02-23 51 views
3

是否可以悬停效果CSS可以在以下情况下使用元素:hover?

我试过这样

.tableclass tr td:hover a{ 
    color:#fff; 
} 

什么,我试图做的是,当我将鼠标悬停在TD所以后来锚是TD内链接应该改变其颜色为以后使用元素白色..

这是我如何尝试自我,但不为我工作?

.GridAlternate td:hover a , .GridRowStyle td:hover a{ 
    color:#fff; 
} 

我的GridView的HTML

<table cellspacing="0" border="1" style="border-collapse:collapse;" id="GV_Users" rules="rows" class="DefaultGridStyle"> 
         <tbody><tr class="GridHeader"> 
          <th scope="col">User Name</th><th scope="col"><a href="javascript:__doPostBack('ctl00$CPH_Content$TC_SysUsers$TP_Users$GV_Users','Sort$RoleName')">Role Name</a></th><th valign="middle" align="left" style="width:22%;" scope="col">LogIn</th><th valign="middle" align="center" style="width:33%;" scope="col">Action</th> 
         </tr><tr class="GridRowStyle"> 
          <td> 
           Ali Nisarr 
          </td><td> 
           Admin 
          </td><td valign="middle" align="left"> 
           [email protected] 
          </td><td valign="middle" align="center"> 
           <a href="javascript:__doPostBack('ctl00$CPH_Content$TC_SysUsers$TP_Users$GV_Users$ctl02$Lbtn_change','')" class="editlinkbutton" id="Lbtn_change">Edit</a> 
           <a href="javascript:__doPostBack('ctl00$CPH_Content$TC_SysUsers$TP_Users$GV_Users$ctl02$Lbtn_Remove','')" class="removelinkbutton" id="Lbtn_Remove">Remove</a> 

           <a href="javascript:__doPostBack('ctl00$CPH_Content$TC_SysUsers$TP_Users$GV_Users$ctl02$Lbtn_Disable','')" class="removelinkbutton" id="Lbtn_Disable">Disable</a> 

          </td> 
         </tr><tr class="GridAlternate"> 
          <td> 
           Nizam Ullah 
          </td><td> 
           Admin 
          </td><td valign="middle" align="left"> 
           [email protected] 
          </td><td valign="middle" align="center"> 
           <a href="javascript:__doPostBack('ctl00$CPH_Content$TC_SysUsers$TP_Users$GV_Users$ctl03$Lbtn_change','')" class="editlinkbutton" id="Lbtn_change">Edit</a> 
           <a href="javascript:__doPostBack('ctl00$CPH_Content$TC_SysUsers$TP_Users$GV_Users$ctl03$Lbtn_Remove','')" class="removelinkbutton" id="Lbtn_Remove">Remove</a> 

           <a href="javascript:__doPostBack('ctl00$CPH_Content$TC_SysUsers$TP_Users$GV_Users$ctl03$Lbtn_Disable','')" class="removelinkbutton" id="Lbtn_Disable">Disable</a> 

          </td> 
         </tr><tr> 
          <td colspan="4"> 
         <table class="GridPager"> 
          <tbody><tr> 
           <td width="7%"> 
            Showing 
            : 
           </td> 
           <td width="5%"> 
            <span id="lbl_rowstartindex">1</span> 
            &nbsp;- 
           </td> 
           <td> 
            <span id="lbl_rowendindex">2</span> 
           </td> 
           <td> 
            of 
           </td> 
           <td> 
            <span id="lbl_totalrecords">2</span> 
           </td> 

           <td width="50%" align="center"> 

            &nbsp; 

            &nbsp; 

            &nbsp; 

            &nbsp; 

            &nbsp; 

            &nbsp; 

           </td> 
           <td width="18%" align="right"> 
            Displaying per page: 
           </td> 
           <td align="left"> 
            <input type="text" id="TxBx_PageSize" maxlength="3" value="10" name="ctl00$CPH_Content$TC_SysUsers$TP_Users$GV_Users$ctl05$TxBx_PageSize"> 

           </td> 
           <td align="left"> 
            <a href="javascript:__doPostBack('ctl00$CPH_Content$TC_SysUsers$TP_Users$GV_Users$ctl05$lb_Change_RowsPerChange','')" id="lb_Change_RowsPerChange">Change</a> 
           </td> 
          </tr> 
         </tbody></table> 
        </td> 
         </tr> 
        </tbody></table> 

我做得不对或有任何其他的方法,我应该遵循?

+3

你试过了吗? – 2013-02-23 05:34:23

+0

是的,我尝试过但可能是我认为我做错了什么? – 2013-02-23 05:36:21

+1

举一个例子来演示你的问题。 – 2013-02-23 05:38:20

回答

2

试试这个;

tr.GridAlternate td:hover a , tr.GridRowStyle td:hover a{ 
    color:#fff; 
} 

并确保将其插入样式表的末尾。 也许它正在被其他课程覆盖。 我希望这可以帮助

+0

是的,它被锚定标签自我覆盖.. 我的意思是 a { color:#660000; } 是在我的CSS后定义的。 – 2013-02-23 06:16:56

0

为什么不试试 .tableclass td:hover a { color:#fff; }

+0

我已经这样做了,但只有当我将鼠标悬停在锚标记上时,颜色才会发生变化。 我想要的是,当我悬停表格的TD元素,然后在该TD所有的锚点标签改变其颜色。 – 2013-02-23 05:43:23

+1

@ user1590011不会更改“”颜色。 – KBN 2013-02-23 05:51:03

+0

它只改变正常的文本颜色 – 2013-02-23 05:55:03

2

http://codepen.io/princemaple/pen/Dcxdi

它完全为我工作。
我假设你的一些规则错误地级联?
像你有更具体的定位规则覆盖这条规则...

+0

是的,它被其他课程所覆盖.. 我的错误.. :( – 2013-02-23 06:18:14

相关问题