admin管理员组文章数量:1391818
I'm trying to rotate an image 45 degree (well actually I really want to make it wiggle back and forth) when I hover over. I tried using CSS with the transform rotate with no luck. Does anyone have any ideas (jQuery, javascript maybe)?
a:hover{
behavior:url(-ms-transform.htc);
/* Firefox */
-moz-transform:rotate(45deg);
/* Safari and Chrome */
-webkit-transform:rotate(45deg);
/* Opera */
-o-transform:rotate(45deg);
/* IE9 */
-ms-transform:rotate(45deg);
/* IE6,IE7 */}
<div id="main">
<span class="box"><a href=""><img src="blog-icon.png"></img></a></span>
</div>
I'm trying to rotate an image 45 degree (well actually I really want to make it wiggle back and forth) when I hover over. I tried using CSS with the transform rotate with no luck. Does anyone have any ideas (jQuery, javascript maybe)?
a:hover{
behavior:url(-ms-transform.htc);
/* Firefox */
-moz-transform:rotate(45deg);
/* Safari and Chrome */
-webkit-transform:rotate(45deg);
/* Opera */
-o-transform:rotate(45deg);
/* IE9 */
-ms-transform:rotate(45deg);
/* IE6,IE7 */}
<div id="main">
<span class="box"><a href=""><img src="blog-icon.png"></img></a></span>
</div>
Share
Improve this question
asked Nov 15, 2012 at 7:16
John VerberJohn Verber
7552 gold badges16 silver badges32 bronze badges
4 Answers
Reset to default 4You seem to be setting the hover to the anchor instead of image..
Instead of
a:hover{
should be
img:hover{
Check Fiddle
In webkit browsers,transform
is ignored on inline elements.
To make this work you would need to add a { display:block; }
to your css. (Inline-block will also work)
Demo: http://jsfiddle/6Df6W/
Try This:
$("a img").rotate({
bind:
{
mouseover : function() {
$(this).rotate({animateTo:45})
},
mouseout : function() {
$(this).rotate({animateTo:0})
}
}
});
I've used this several times and it works well:
http://code.google./p/jqueryrotate/
$(".box a img").rotate(45);
本文标签: javascriptOn hover image rotate 45 degreesStack Overflow
版权声明:本文标题:javascript - On hover image rotate 45 degrees - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744769523a2624252.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论