Opera and Firefox do not accept background-position-x/y
animation. You can try to implement it using a custom plugin.
$('.btn').click(function() {
$('.background').animate({
borderWidth: '1px'
}).animateBG('0', '100px',300);
});
$.fn.animateBG = function(x, y, speed) {
var pos = this.css('background-position').split(' ');
this.x = parseInt(pos[0]) || 0;
this.y = parseInt(pos[1]) || 0;
$.Animation( this, {
x: x,
y: y
}, {
duration: speed
}).progress(function(e) {
this.css('background-position', e.tweens[0].now+'px '+e.tweens[1].now+'px');
});
return this;
}
.background {
width: 300px;
height: 200px;
background: url(http://placehold.it/350x250);
background-size: cover;
border: 5px solid;
border-color: red;
box-sizing: border-box;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<div class='background'></div>
<input type="button" class='btn' value="Button">