2015-12-27 146 views
-1

我的CSS代碼是:CSS - 上懸停做動畫圖像

.logo 
{ 
    width: 20px; 
    height: 20px; 
    display: inline-block !important; 
    -webkit-transition: -webkit-transform .8s ease-in-out; 
    -ms-transition: -ms-transform .8s ease-in-out; 
    transition: transform .8s ease-in-out; 
} 

.logo:hover 
{ 
    transform:rotate(360deg); 
    -ms-transform:rotate(360deg); 
    -webkit-transform:rotate(360deg); 
} 

和HTML是:

<a class="navbar-brand" href="#"> 
    <img src="img/logo200x200.png" class="logo" /> 
    Website 
</a> 

JSFIDDLE

我可以像只有當旋轉不我的鼠標在圖像上,但鼠標在文本上?

+0

什麼短信?顯示html。 (在這個網站上) –

回答

1

只需使用a:hover .logo取代.logo:hover

這裏工作的解決方案:

.logo { 
 
    width: 20px; 
 
    height: 20px; 
 
    display: inline-block !important; 
 
    -webkit-transition: -webkit-transform .8s ease-in-out; 
 
    -ms-transition: -ms-transform .8s ease-in-out; 
 
    transition: transform .8s ease-in-out; 
 
} 
 
a:hover .logo 
 
{ 
 
    transform:rotate(360deg); 
 
    -ms-transform:rotate(360deg); 
 
    -webkit-transform:rotate(360deg); 
 
}
<a class="navbar-brand" href="#"> 
 
    <img src="http://placehold.it/200x200.png" class="logo" />Website 
 
</a>