I’d like to create an auto-scrollable image inside of a div. like, I have a picture that’s 600px wide and 1200px tall and I’d like to display it inside a 600px by 200px div and make it scroll and loop indefinitely. the jQuery plugins I’ve tried are all designed to scroll multiple li items, and I’ve failed hard at adapting it to my needs. so I tried chopping up the image into multiple pieces but that just looks horrid. any pointers?
<style type="text/css">
#autoscroll {
max-height: 100px;
overflow: hidden;
}
</style>
...
<div id="autoscroll">
<img src="someimage.jpg">
</div>
Setup a container with
overflowset tohiddenand the dimensions you want to display. Then add your image as a child of this container and animate its position:HTML
CSS
JS
Note that I animate the
topof the image to the negative of the height of the image minus the height of container ((container.height() – image.height()) * -1).Here is a jsfiddle of the above solution: http://jsfiddle.net/J9BM8/1/