K, . Fiddle: https://jsfiddle.net/pkfxqmLs/2/ ... , - , RAF . , .. , 100% , , - , ..., , , .
div div, .
HTML:
<div id="coke">
<img id="bottle-mask" src="http://ipbyrne.imtqy.com/bottle-demo/mask.svg" width="156" height="467"/>
<img id="bottle-label" src="http://ipbyrne.imtqy.com/bottle-demo/label.png"/>
<img id="bottle-overlay" src="http://ipbyrne.imtqy.com/bottle-demo/overlay.png" width="156" height="467" alt="Pure CSS Coke Can by Román Cortés" />
<div id="pusher"></div>
</div>
JS:
(function(){
var number = 1
var box=document.getElementById('coke');
function infScroll(){
box.scrollLeft += number;
if(box.scrollLeft===160){
number = number * -1;
}
if(box.scrollLeft === 0) {
number = number * -1;
}
window.requestAnimationFrame(infScroll);
}
window.requestAnimationFrame(infScroll);
}());
CSS
{ margin: 0; : 0; : 100%; }
#coke
{
width: 156px;
height: 500px;
overflow: auto;
position:relative;
}
#bottle-mask {
position:fixed;
left:0px;
z-index:1;
}
#bottle-label {
position: absolute;
top: 140px;
width: 325px;
height: 250px;
z-index: 2;
}
#bottle-overlay {
position: fixed;
left:0px;
z-index: 3;
}
#pusher {
width: 325px;
height: 500px;
position: relative;
z-index: 4;
}
source
share