📜 ⬆️ ⬇️

Jungle effect


Today I stumbled upon one site, the background of which is scrolled when the browser window is resized, cool, nothing can be said, but that was not enough for me. Therefore, I wanted to make it so that the background scrolled constantly without any hyphae and flash. Turned on your favorite music and ... voila! :)
What I dashed here uses jQuery, and it was written very quickly. Therefore, do not kick much :)

Where can this be applied? Well, certainly not on the whole site, but for a postcard or a page-business card \ presentation - I think the most it :)


1. HTML


We have only three drawings, so for the first drawing we have a body, for the other two we create two divas and immediately close them. But, since these two divas will just go nuts, how big they are, we put them into another div:
<div id="overflow">
<div id="midground"></div>
<div id="foreground"></div>
</div>

Of course, for content, we have a separate div:
<div id="content">
<!-- content goes here -->
</div>

')

2. CSS


Now go with the styles. , .
#overflow { width: 100%; overflow: hidden; height: 500px; position: absolute; }

, , :
#midground {
background: transparent url(bg-mid.png) left top repeat-x;
margin: 0; padding: 0; width: 1000%;
position: absolute; top: 0;
height: 600px;
z-index: 1;
}
#foreground {
background: transparent url(bg-front.png) left top repeat-x;
margin: 0; padding: 0; width: 1000%; height: 200px;
position: absolute; top: 0; left: -9000px;
z-index: 2;
}


3. jQuery
, :

init.js: $(document).ready(function() {
$('#midground').animate({left: "-=9000px"}, { easing: "linear", duration:120000 });
$('#foreground').animate({left: "+=9000px"}, { easing: "linear", duration:120000 });
});

, , .

1. $(document).ready — html/js .
2. $() - jQuery, css- xpath
3. $.animate() - , css (easing)
4. $.animate({left: "+=9000px"}) - - . - .
5. {easing: "linear", duration: 120000} - (easing) "linear", , , .. jQuery "swing". .. . duration: 120000 - , self-explanatory, .
6. , - , :)

, , , .
! :)

: Firefox 2, Opera 9.26, Internet Explorer 7, Safari 3.0.4.
IE 6 , - , :)

, .
#overflow { width: 100%; overflow: hidden; height: 500px; position: absolute; }

, , :
#midground {
background: transparent url(bg-mid.png) left top repeat-x;
margin: 0; padding: 0; width: 1000%;
position: absolute; top: 0;
height: 600px;
z-index: 1;
}
#foreground {
background: transparent url(bg-front.png) left top repeat-x;
margin: 0; padding: 0; width: 1000%; height: 200px;
position: absolute; top: 0; left: -9000px;
z-index: 2;
}


3. jQuery
, :

init.js: $(document).ready(function() {
$('#midground').animate({left: "-=9000px"}, { easing: "linear", duration:120000 });
$('#foreground').animate({left: "+=9000px"}, { easing: "linear", duration:120000 });
});

, , .

1. $(document).ready — html/js .
2. $() - jQuery, css- xpath
3. $.animate() - , css (easing)
4. $.animate({left: "+=9000px"}) - - . - .
5. {easing: "linear", duration: 120000} - (easing) "linear", , , .. jQuery "swing". .. . duration: 120000 - , self-explanatory, .
6. , - , :)

, , , .
! :)

: Firefox 2, Opera 9.26, Internet Explorer 7, Safari 3.0.4.
IE 6 , - , :)

, .
#overflow { width: 100%; overflow: hidden; height: 500px; position: absolute; }

, , :
#midground {
background: transparent url(bg-mid.png) left top repeat-x;
margin: 0; padding: 0; width: 1000%;
position: absolute; top: 0;
height: 600px;
z-index: 1;
}
#foreground {
background: transparent url(bg-front.png) left top repeat-x;
margin: 0; padding: 0; width: 1000%; height: 200px;
position: absolute; top: 0; left: -9000px;
z-index: 2;
}


3. jQuery
, :

init.js: $(document).ready(function() {
$('#midground').animate({left: "-=9000px"}, { easing: "linear", duration:120000 });
$('#foreground').animate({left: "+=9000px"}, { easing: "linear", duration:120000 });
});

, , .

1. $(document).ready — html/js .
2. $() - jQuery, css- xpath
3. $.animate() - , css (easing)
4. $.animate({left: "+=9000px"}) - - . - .
5. {easing: "linear", duration: 120000} - (easing) "linear", , , .. jQuery "swing". .. . duration: 120000 - , self-explanatory, .
6. , - , :)

, , , .
! :)

: Firefox 2, Opera 9.26, Internet Explorer 7, Safari 3.0.4.
IE 6 , - , :)

, .
#overflow { width: 100%; overflow: hidden; height: 500px; position: absolute; }

, , :
#midground {
background: transparent url(bg-mid.png) left top repeat-x;
margin: 0; padding: 0; width: 1000%;
position: absolute; top: 0;
height: 600px;
z-index: 1;
}
#foreground {
background: transparent url(bg-front.png) left top repeat-x;
margin: 0; padding: 0; width: 1000%; height: 200px;
position: absolute; top: 0; left: -9000px;
z-index: 2;
}


3. jQuery
, :

init.js: $(document).ready(function() {
$('#midground').animate({left: "-=9000px"}, { easing: "linear", duration:120000 });
$('#foreground').animate({left: "+=9000px"}, { easing: "linear", duration:120000 });
});

, , .

1. $(document).ready — html/js .
2. $() - jQuery, css- xpath
3. $.animate() - , css (easing)
4. $.animate({left: "+=9000px"}) - - . - .
5. {easing: "linear", duration: 120000} - (easing) "linear", , , .. jQuery "swing". .. . duration: 120000 - , self-explanatory, .
6. , - , :)

, , , .
! :)

: Firefox 2, Opera 9.26, Internet Explorer 7, Safari 3.0.4.
IE 6 , - , :)

, .
#overflow { width: 100%; overflow: hidden; height: 500px; position: absolute; }

, , :
#midground {
background: transparent url(bg-mid.png) left top repeat-x;
margin: 0; padding: 0; width: 1000%;
position: absolute; top: 0;
height: 600px;
z-index: 1;
}
#foreground {
background: transparent url(bg-front.png) left top repeat-x;
margin: 0; padding: 0; width: 1000%; height: 200px;
position: absolute; top: 0; left: -9000px;
z-index: 2;
}


3. jQuery
, :

init.js: $(document).ready(function() {
$('#midground').animate({left: "-=9000px"}, { easing: "linear", duration:120000 });
$('#foreground').animate({left: "+=9000px"}, { easing: "linear", duration:120000 });
});

, , .

1. $(document).ready — html/js .
2. $() - jQuery, css- xpath
3. $.animate() - , css (easing)
4. $.animate({left: "+=9000px"}) - - . - .
5. {easing: "linear", duration: 120000} - (easing) "linear", , , .. jQuery "swing". .. . duration: 120000 - , self-explanatory, .
6. , - , :)

, , , .
! :)

: Firefox 2, Opera 9.26, Internet Explorer 7, Safari 3.0.4.
IE 6 , - , :)

Source: https://habr.com/ru/post/21070/


All Articles