我的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>
不仅可以在鼠标位于图像上时,还可以在鼠标在文本上时使图像旋转吗?
答案 0 :(得分:2)
答案 1 :(得分:1)
只需将.logo:hover
替换为a:hover .logo
!
这是工作解决方案:
.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);
}
&#13;
<a class="navbar-brand" href="#">
<img src="http://placehold.it/200x200.png" class="logo" />Website
</a>
&#13;