배경 이미지를 끝 픽셀까지 스크롤 한 다음 이미지의 시작 부분으로 뒤로 이동하고 싶습니다. 그 순서를 계속 반복하고 싶습니다.배경 이미지 스크롤
코드가 있지만 배경 이미지를 한 방향으로 연속적으로 스크롤합니다.
내가 원하는대로이 코드를 어떻게 변경할 수 있습니까?
CSS :
body{margin:0; border:0; background:url(ejemplo3.jpg) repeat-x;}
HTML :
<body></body>
JQuery와 : 나는 당신이 필요로 이해하고 이미지의 높이 경우에 따라
var scrollSpeed = 50;
// set the default position
var current = 0;
// set the direction
var direction = 'h';
function bgscroll() {
// 1 pixel row at a time
current -= 1;
// move the background with backgrond-position css properties
$('body').css("backgroundPosition", (direction == 'h') ? current + "px 0" : "0 " + current + "px");
}
//Calls the scrolling function repeatedly
setInterval(bgscroll, scrollSpeed);
아쇽 덕분에 정말 감사합니다! 코드가 완벽하게 작동합니다. – user3375954
안녕하세요, 1024 또는 1480과 같은 화면 해상도가 배경 이미지가 최종 픽셀 (가로)에 도달하지 않거나 최종 픽셀 (가로)을 초과 할 때 코드에 문제가 있습니다. 어떻게 해결할 수 있습니까? 다음은 온라인 예입니다. http://www.ideas-web.net63.net/prueba/prueba.html – user3375954