能否对 transform: rotate(Xdeg);
进行动画效果呢?
例如,我有一个id为“awesomeDiv”的div
,并尝试在悬停时旋转它。
它应该从-24度
旋转到0度
,并在鼠标移出时再从0度
旋转回-24度
。
我已经尝试了以下方法:
$("#awesomeDiv").hover(
function()
{
$(this).animate({
transform : "rotate(0deg)"
});
},
function()
{
$(this).animate({
transform: "rotate(-24deg)"
});
}
);
div#awesomeDiv {
position: absolute;
background-color: #D8D8D8;
width: 200px;
height: 200px;
transform: rotate(-24deg);
margin-left:30px;
margin-top: 30px;
background-image: url("http://ih0.redbubble.net/image.218467778.5415/fc,220x200,white.u2.jpg");
}
div#centerMe {
position: relative;
margin-top: 92px;
color: white;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="awesomeDiv">
<div id="centerMe">
<center>Im Aw<span style="color:black">es</span>ome!</center>
</div>
</div>