Here is my working page。我将按钮连接到白色主教,您可以左右移动,但左侧图像与右侧图像重叠。我认为问题在于CSS。简要的结构在这里。jQuery的背景图片重叠问题
<script>
$(document).ready(function(){
$('#top').click(function(){
$('#p81').animate({top: "-=64px"}, 100);
});
</script>
<style>
div.chess_board{
height: 512px;
position: relative;
width: 512px;
}
div.chess_square{
height:64px;
position: absolute;
width:64px;
}
div.chess_square.white {
background: none repeat scroll 0 0 #ffffff;
}
.
.
.
div.chess_piece{
background-image: url("sprite.png");
height: 64px;
width: 64px;
position: absolute;
}
div.chess_piece.bishot.white{
background-position: -64px 0;
}
</style>
<div class="chess_board">
<div id="b81" class="chess_square white" style="top: 448px; left: 64px;">
<div class="chess_square_inner"></div>
<div id="p81" class="chess_piece bishot white"></div>
</div>
</div>
<input type="button" id="top" value="top" />
您能举出一个在线示例吗?这在人们的脑海中很难想象。而且,作为基本规则,我建议将' '放入这些DIV中,以便它们在所有浏览器中正确渲染。 – 2010-03-28 17:04:23
感谢您快速回复Pekka。我已经把链接http://aafggucb.facebook.joyent.us/chess.html请看看它! – Devyn 2010-03-28 17:06:35