简体   繁体   English

解析“背景位置”的值时出错

[英]Error in parsing value for 'background-position'

I want to animate my menu. 我想为菜单制作动画。 But nothing happens, I only receive the following error in the console: "Error in parsing value for 'background-position'". 但是什么也没有发生,我在控制台中仅收到以下错误:“解析'background-position'的值时出错”。

Can you please help me? 你能帮我么?

CSS: CSS:

nav li a {
            display:block;
            height:96px;
            width:124px;
            color:#818080;
            text-align:center;
            text-decoration:none;
            padding-top:60px;
            background:url(../img/n1-hover.gif) 0 -146px no-repeat;
        }

JavaScript 的JavaScript

  $(document).ready(function() {                    
        $('.menu a').hover(
        function(){$(this).stop().animate({backgroundPosition:'0px 0px'}, 800, 'easeOutBounce')}, 
        function(){$(this).stop().animate({backgroundPosition:'0px -146px'}, 600, 'easeOutBounce')});  
    }); 

I forgot to mention, that I'm using the plugin JQuery Easing . 我忘了提一下,我正在使用插件JQuery Easing

Remove px part from backgroun position it should work fine. 从背景位置删除px部分,它应该可以正常工作。 Try this 尝试这个

$(document).ready(function() {                    
                $('.menu a').hover(
                function(){$(this).stop().animate({backgroundPosition:'0 0'}, 800, 'easeOutBounce')}, 
                function(){$(this).stop().animate({backgroundPosition:'0 -146'}, 600, 'easeOutBounce')});  
            }); 

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

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