简体   繁体   English

使用jquery动画效果对图像进行动画处理

[英]Animate image with jquery Animation effect

I am trying to animate top menus with jQuery for this website http://www.homeprideflour.co.uk/index.htm 我正在尝试使用jQuery为该网站的顶部菜单设置动画,网址为http://www.homeprideflour.co.uk/index.htm

I am not been able to animate products and collectiables menu image hover animation. 我无法为产品和收藏品菜单图像悬停动画制作动画。 I am using hover images as background and changing their position with Jquery. 我将悬停图像用作背景,并使用Jquery更改了它们的位置。 Here is my code 这是我的代码

$('.liproduct a').mouseover(function(){

        $('.prodimg').stop().animate(
        {backgroundPosition:"(50% 0px)"}, 
            {duration:600})
        })
    .mouseout(function(){
        $('.prodimg').stop().animate(
            {backgroundPosition:"(50% 100px)"}, 
            {duration:600})
        })  

Can anyone suggest me how to achieve the mouseover effect same as product menu in above mentioned URL. 谁能建议我如何实现与上述URL中的产品菜单相同的鼠标悬停效果。

Thanks 谢谢

I haven't tested this but ths is how I would approach: 我还没有测试过,但是这就是我的处理方式:

var $prodImg = $('.prodimg');
$('.liproduct a').on("hover",function(){
        $prodImg.stop().animate(
        {backgroundPosition:"(50% 0px)"},
            {duration:600})
        },
        function(){
        $prodImg.stop().animate(
            {backgroundPosition:"(50% 100px)"},
            {duration:600})
        });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM