2013-02-23 48 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

相關問題