How to Create Scrollable Image Slider Using JavaScript

Scrollable image slider  is one of the interesting features in the image gallery application. This allows us to display thumbnails in the form of slides that can be scrolled automatically or manually using the control buttons.

Figure below shows a scrollable image slider featuring four thumbnails per slide. To display thumbnails from another slide, simply by clicking the navigation buttons located on the right and left slide. Slides can also be scrolled automatically by using the  left and right arrow keyboard or using  the mouse wheel.

Scrollable image gallery

Scrollable image slider

In this tutorial, i’ll use Scrollable component from jQuery Tools user interface (UI) library which is based on popular jQuery javascript framework. Current version of jQuery Tools at the time of this writing is version 1.1.2, which can be downloaded here. The library itself consists of six user interface components that can be easily combined:  Tabs, Tooltip, Overlay, Scrollable, Expose, and Flashembed.

How to Setup

  • Download Scrollable component from download page and save it as You can download it with jQuery (v1.3.2)  as a single file (21.75 kb) or as a separated file (3.37 kb) if you already have jQuery.
  • Include the in the HEAD section of your HTML file
  • <script src="scripts/" type="text/javascript"></script>


    <script src="scripts/jquery-1.3.2.min.js" type="text/javascript"></script>
    <script src="scripts/" type="text/javascript"></script>

Using Scrollable UI library


<a class="prevPage left"></a>
<div class="scrollable">
    <div class="items">
        <!-- 1-4 -->
        <img src="" />
        <img src="" />
        <img src="" />
        <img src="" />

        <!-- 5-8 -->
        <img src="" />
        <img src="" />
        <img src="" />
        <img src="" />

        <!-- 10-12 -->
        <img src="" />
        <img src="" />
        <img src="" />
        <img src="" />

<a class="nextPage right"></a>

line 01:  element for left/prev  button.

line 02: root element (div) for the scrollable.

line 03: wrapper element.

line 04-20: scrollable images (will be displayed  four images per slide).

line 24: element for right/next button.

CSS Code


.scrollable {
	background: #ccc;
	position: relative;
	overflow: hidden;
	width: 690px;
	border:1px solid #ccc;

.scrollable .items {
	width: 20000em;
	position: absolute;
	clear: both;

.scrollable img {
    opacity: 0.6;
	margin:15px 5px 15px 15px;

.scrollable .active {
	border:2px solid #000;

line 01, style for  container element, the length and width depends on image size and how many images you want displayed per slide.

line 12, style for wrapper element.

line 18,  style for images in a slide.

line 30, style for selected image.

Navigation button (prev & next)

.scrollable { float:left; }

a.left, a.right {
	display: block;
	width: 18px;
	height: 18px;
	float: left;
	margin: 60px 10px;
	cursor: pointer;

a.right { background: url(scrollable/arrow/right.png) no-repeat;  clear:right; margin-right: 0px;}
a.right:hover  { background-position:0px -18px; }
a.right:active 	{ background-position:0px 0px; }

a.left	{ background: url(scrollable/arrow/left.png) no-repeat;  margin-left: 0px; }
a.left:hover  { background-position:0px -18px; }
a.left:active  { background-position:-0px 0px; }

a.disabled { visibility:hidden !important; }

line 01, allow next and  prev buttons placed on each side of the slide.

line 12,  set size and position of prev and next buttons.

line 16,  set background image for prev and next buttons.

Javascript Code

	$(function()  { $("div.scrollable").scrollable({size: 4}); });

$(“div.scrollable”) is a jQuery selector for scrollabe container. On example above, we set four images for each slide using configuration parameter ‘size‘. Default value of ‘size‘ parameter is 5. You can learn more about the API of the Scrollable component on this page.

facebooktwittergoogle_plusredditpinterestlinkedinmailby feather


  1. cre8tvnrg says

    I am looking for a scrollable gallery like this (Non-Flash) that shows all thumbnail images black and white – then when you roll over a thumbnail image it becomes full color AND populates in a full size larger cell above the gallery scroll bar, is this possible? If so, how would this be accomplished?
    Please advise?

  2. Johnathan says

    Thank you so much for this tutorial! This will surly! I can now finish my website off for a college assignment!

  3. Johnathan says

    Thank you so much for this tutorial! This will surly help me finish my website off for a college assignment!*

    God knows what I typed before…

  4. guitarcal says

    How would you modify this to display information text when each picture is clicked on a different portion on your website?

Leave a Reply

Your email address will not be published. Required fields are marked *