2016-10-10 80 views
0

我想在懸停時顯示不同顏色的字形圖標。如何更改懸停在div標籤內的標誌符號圖標顏色?

這是我的代碼:

<div class="col-xs-3 col-lg-3 text-center span-hover" style="height:50px;border-right: 1px solid #fff;" data-target="#myCarousel" data-slide-to="1"> 
     <span class="glyphicon glyphicon-globe"></span> 
     <span class="hidden-xs">&nbsp;TRADING</span> 
    </div> 

CSS

.span-hover:hover {     
    background-color: rgba(0,0,0,0.4); 
    color:white; 
} 
.glyphicon 
{ 
    font-size: 25px; 
    color:red; 
} 
.glyphicon:hover 
{ 
    color:#44c5ff; 
} 

當用戶將光標放在div標籤,現在,它只是改變文本色系我想改變文字顏色:白色,同時字形圖標顏色:#44c5ff;

.glyphicon:hover當用戶將光標放在glyphicon上時,它正在工作。但不是在div標籤。

感謝

+2

'.span懸停在:hover {.glyphicon顏色:#44c5ff; }' –

+0

。glyphicon:hover {color:red;}其工作檢查在我的代碼片段中 –

回答

0

<!DOCTYPE html> 
 
<html> 
 
    <head> 
 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
 
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> 
 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> 
 
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 
 
<style> 
 
.glyphicon:hover{ 
 
color:#44c5ff; 
 
font-size:30px; 
 
} 
 
</style> 
 
    </head> 
 

 
    <body> 
 
    <div class="container"> 
 
     <h2>Glyphicon Examples</h2> 
 
     <p>Envelope icon: <span class="glyphicon glyphicon-envelope"></span></p>  
 
     <p>Envelope icon as a link: 
 
     <a href="#"> 
 
      <span class="glyphicon glyphicon-envelope"></span> 
 
     </a> 
 
     </p> 
 
     <p>Search icon: <span class="glyphicon glyphicon-search"></span></p> 
 
     <p>Search icon on a button: 
 
     <button type="button" class="btn btn-default"> 
 
      <span class="glyphicon glyphicon-search"></span> Search 
 
     </button> 
 
     </p> 
 
     <p>Search icon on a styled button: 
 
     <button type="button" class="btn btn-info"> 
 
      <span class="glyphicon glyphicon-search"></span> Search 
 
     </button> 
 
     </p> 
 
     <p>Print icon: <span class="glyphicon glyphicon-print"></span></p>  
 
     <p>Print icon on a styled link button: 
 
     <a href="#" class="btn btn-success btn-lg"> 
 
      <span class="glyphicon glyphicon-print"></span> Print 
 
     </a> 
 
     </p> 
 
    </div> 
 
    
 
    </body> 
 
</html>
試一次

0

.span-hover:hover {     
 
    background-color: rgba(0,0,0,0.4); 
 
    color:white; 
 
} 
 
.glyphicon 
 
{ 
 
    font-size: 25px; 
 
    color:red; 
 
} 
 
.glyphicon:hover 
 
{ 
 
    color:#44c5ff; 
 
} 
 
.span-hover:hover .glyphicon{ 
 
    color:#44c5ff; 
 
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> 
 
<div class="col-xs-3 col-lg-3 text-center span-hover" style="height:50px;border-right: 1px solid #fff;" data-target="#myCarousel" data-slide-to="1"> 
 
    <span class="glyphicon glyphicon-globe"></span> 
 
    <span class="hidden-xs">&nbsp;TRADING</span> 
 
</div>
試試這個片斷。你可以使用這種類型的懸停

.span-hover:hover .glyphicon{ color:#44c5ff; }

相關問題