如何满足您的需求:http: //jsfiddle.net/HMKXq/
或者这里的动画演示:http: //jsfiddle.net/HMKXq/2/
好的来源:使用 jQuery 在切换时旋转图像
希望能帮助到你:)
代码
$(document).ready(function () {
$('.menu-category-title').click(function () {
$('#menu-' + $(this).attr('hook')).fadeToggle('slow');
$(this).children('.menu-title-arrow').toggleClass("rotate1 rotate2");
});
});
css
.menu-category-title {
position: relative;
height: 70px;
line-height: 70px;
text-transform: uppercase;
letter-spacing: 1px;
font-size: 20px;
border-bottom: 1px solid black;
cursor: pointer;
}
.menu-food-wrap {
position: relative;
margin-top: 25px;
padding-bottom: 45px;
text-transform: uppercase;
font-size: 12px;
line-height: 15px;
border-bottom: 1px solid black;
display: none;
}
.rotate1 {
-webkit-transform: rotate(0deg) translate3d(0, 0, 0);
-moz-transform: rotate(0deg);
-o-transform: rotate(0deg);
-ms-transform: rotate(0deg);
transform: rotate(0deg);
-o-transition:.5s;
-ms-transition:.5s;
-moz-transition:.5s;
-webkit-transition:.5s;
transition:.5s;
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=0);
}
.rotate2 {
-webkit-transform: rotate(-180deg) translate3d(0, 0, 0);
-moz-transform: rotate(-180deg);
-o-transform: rotate(-180deg);
-ms-transform: rotate(-180deg);
transform: rotate(-180deg);
-o-transition:.5s;
-ms-transition:.5s;
-moz-transition:.5s;
-webkit-transition:.5s;
transition:.5s;
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=2);
}