0

jquery アニメーションを使用して分割の背景画像を移動しようとしていますが、移動していません。移動しようとすると、画像が揺れるだけです。スライドショーを作成し、背景画像を移動させたい、クリックすると背景画像が完全に分割され、クリックするとサイズが維持され、右または左に移動する必要があります.こちらのコードを確認してください http://jsfiddle.net/sSYKD/1/

<!DOCTYPE html>
<html>
<head>
<script src="jquery-1.8.js"></script>
<style>

.blueScreen {
background:url(http://s21.postimg.org/quy8jsc0n/blue_Screen.png);
background-size:100% 100%;
width:100%;
height:500px;

}
.contentBlueScreen {
display:inline-block;
color:white;
background:url(http://i.imgur.com/a5m0HGp.png);
background-size:100% 100%;
width:100%;
height:500px;
}
</style>
<script>
$(document).ready(function() {
$("#theButton").click(function() {
$(".contentBlueScreen").animate({backgroundPosition:"200%"},3000);
});
});
</script>
</head>
<body>

<div class="blueScreen">
<div class="contentBlueScreen">
<button id="theButton">MOve it</button>
</div>
</div>
</body>
</html>
4

2 に答える 2

0

div全体を移動するだけです。

実施例

JS

$(document).ready(function () {
    $("#theButton").click(function () {
        $(".contentBlueScreen").animate({
            left: "200%"
        }, 1500).animate({
            left: 0
        }, 1500);
    });
});

CSS

.blueScreen {
    background:url(http://s21.postimg.org/quy8jsc0n/blue_Screen.png);
    background-size:100% 100%;
    width:100%;
    height:100%;
    overflow:hidden;
}
.contentBlueScreen {
    position:relative;
    display:inline-block;
    color:white;
    width:400%;
    height:100%;
}
img {
   float:left;
    list-style:none;
    position:relative;
    width:25%;
    height:500px;
    position:relative;

}

HTML

<div class="blueScreen">
    <button id="theButton">MOve it</button>
    <div class="contentBlueScreen">
        <img src="http://i.imgur.com/a5m0HGp.png"/>
        <img src="http://i.imgur.com/a5m0HGp.png"/>
        <img src="http://i.imgur.com/a5m0HGp.png"/>
        <img src="http://i.imgur.com/a5m0HGp.png"/>
    </div>
</div>
于 2013-06-07T02:24:32.367 に答える