Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7080079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:45:03+00:00 2026-05-28T06:45:03+00:00

I have this simple HTML: <span class=coverImg style=background-image:url(‘images/show2.jpg’);></span></a> and some Javascript: $(function() { $(.coverImg).hover(function()

  • 0

I have this simple HTML:

<span class="coverImg" style="background-image:url('images/show2.jpg');"></span></a>

and some Javascript:

$(function() {
            $(".coverImg").hover(function() {
                $(this).animate({
                    backgroundPosition : "0 0"
                }, "fast");
            }, function() {
                $(this).animate({
                    backgroundPosition : "50% 50%"
                }, "fast");
            });
        });

so when the mouseover the function is work correctly although the animation is not so perfect nice and easing is hardly seen..
but when mouseout the function is not working ,the background image just sit there not moving even on pixel…

What’s the problem? What have I missed?

OR:

$(function() {
            $(".coverImg").mouseover(function() {
                $(this)
                .animate({
                    "background-position-x" : "-=20px",
                    "background-position-y" : "-=20px"
                }, "fast");
            }).mouseout(function() {
                $(this).animate({
                    "background-position-x" : "0 ",
                    "background-position-y" : "0"
                }, "fast");
            })
        })

this works only in the Chrome…

so again what’s the problem ! what’s the bug ! what i have miss?!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T06:45:03+00:00Added an answer on May 28, 2026 at 6:45 am

    I don’t think jQuery can animate background positions be default — I use http://archive.plugins.jquery.com/project/backgroundPosition-Effect

    The standard CSS does not support the background-position-x and background-position-y, only a few support this like Chrome.

    And jQuery’s animate() method does not support animate two values at the same time, it’ll turn out to be a error sometime or just do not doing anything in some browsers.

    So after all, check this out http://snook.ca/archives/javascript/jquery-bg-image-animations. There should be a jQuery plugin called jQuery.bgpos.js that works very well if you want to animate the background position.

    Code is like this:

    (function($) {
    $.extend($.fx.step, {
        backgroundPosition : function(fx) {
            if(fx.state === 0 && typeof fx.end == 'string') {
                var start = $.curCSS(fx.elem, 'backgroundPosition');
                start = toArray(start);
                fx.start = [start[0], start[2]];
                var end = toArray(fx.end);
                fx.end = [end[0], end[2]];
                fx.unit = [end[1], end[3]];
            }
            var nowPosX = [];
            nowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0];
            nowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1];
            fx.elem.style.backgroundPosition = nowPosX[0] + ' ' + nowPosX[1];
            function toArray(strg) {
                strg = strg.replace(/left|top/g, '0px');
                strg = strg.replace(/right|bottom/g, '100%');
                strg = strg.replace(/([0-9\.]+)(\s|\)|$)/g, "$1px$2");
                var res = strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);
                return [parseFloat(res[1], 10), res[2], parseFloat(res[3], 10), res[4]];
            }
    
        }
    });})(jQuery);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this html right now: <h1><span class = 'highlight'><input type='image' class='removeall' src='remove.png'> <input
Take a very simple case as an example, say I have this URL: http://www.example.com/65167.html
I have this html page which is very simple, it contains a text box
I have a simple html multiline tooltip implementation: this.tooltip = function(tag) { xOffset =
I have a simple app with a full screen UIWebView. This contains HTML generated
This is probably a basic html/css question... I have a simple one-button form that
I have this simple Jsp page: <%@ page language=java import=java.awt.Color%> <% Color background =
By default Html.ValidationSummary() produces HTML like this: <span class=validation-summary-errors>There were some errors...</span> <ul class=validation-summary-errors>
I have a template like this: <script id=notesTemplate type=text/html> <li class=Note> <div class=NoteDate data-bind=style:
I've made some pretty checkboxes using some pretty simple jQuery HTML <span class=iconElement checkBox

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.