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);
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744769523a4592672.html
评论列表(0条)