Step By Step To Create Content Slider using jFlow, A Minimalist jQuery Plugin

There are a lot of free scripts to create a content slider. One of the example is SmoothGallery by JonDesign. But, if you are using jQuery and don’t want to install another JavaScript library, then you may need to consider jQuery slider plugin.

Today, i am going to provide a tutorial on using jFlow, a minimalist jQuery plugin to create a content slider. Readers are required to have basic XHTML/CSS and JavaScript skills. I will provide a download link after this tutorial. This is the first tutorial post on WebDesignBooth, and i will write more tutorials in future.

slides: “#slides”, // the div where all your sliding divs are nested in

controller: “.jFlowControl”, // must be class, use . sign

slideWrapper : “#jFlowSlide”, // must be id, use # sign

selectedWrapper: “jFlowSelected”, // just pure text, no sign

width: “610px”, // this is the width for the content-slider

height: “235px”, // this is the height for the content-slider

duration: 400, // time in miliseconds to transition one slide

prev: “.jFlowPrev”, // must be class, use . sign

next: “.jFlowNext”// must be class, use . sign

});

});

</script>

Think #slides as a container, which contain all slides, while .jFlowControlis the controller which let us go to the individual slide. As you can see from the style.css, we have 300px .slide-thumbnail to display our image, 290px .slide-details to display our title and description. Besides these, we have 10px margin-left for the .slide-description and 5px padding for the .slide-wrapper. So totally we need 610px width. For the “height” setting, you need to estimate the maximum height for your content. Here, i will use 235px as an example.

Now is the turn to create the individual slide. The slide is contained in the #slides div. Here, i will conly show one slide. You may refer the source code for more info.

view plaincopy to clipboardprint?

<div class=“slide-wrapper”>

<div class=“slide-thumbnail”>

<!– image here –>

</div>

<div class=“slide-details”>

<h2><!– title here –></h2>

<div class=“description”>

<!– description here. –>

</div>

</div>

<div class=“clear”></div>

</div>

We will wrap everything in a .slide-wrapper class, and float our thumbnail to the left while our content to the right. Don’t forget to clear the floats also. Replace image, title, and description with your own content.

After that, we may add controls to the slides, which are resides in a #myController div.

view plaincopy to clipboardprint?

<span class=“jFlowPrev”>Prev</span>

<span class=“jFlowControl”>1</span>

<span class=“jFlowNext”>Next</span>

The .jFlowPrev and .jFlowNext are necessary controls to go to previous and next slides, while .jFlowControl is a “button” to jump to any particular slide. The number of .jFlowControl span is depends on the number of slides you have.

That’s all!! We had done everything. You can view the demo or download the source code to use in your own project.