
How to install and style jCarousel Lite

jCarousel Lite is actually a stripped down version of the original jCarousel jQuery plugin, with lesser ability but more simplicity. It’s a perfect solution for those who are trying to easily make an image scroller using jQuery, it only weights around 2KB, which means you don’t have to go through a lot of coding stuff to get started. But then again, the one thing that always bothered me is that even though the basic goal was to release something real simple and feather-weight, the simplicity don’t really come in handy for most people because of the poor documentation(no offence, it could be just me). So here I am, with a not-really-pro tutorial on how you could make and style an image scroller using jCarousel Lite.
The very first thing you’ll need is the jQuery Library to run jCarousel Lite, for your convenience, I’ve put together a download package with both of them in it. You can download it from HERE (118KB). You’ll find them in the js folder once you have unzipped the package, it also contains an example image scroller which you can start using right away. Now, let’s move on to the tutorial.
You’ll most likely be able to to figure out everything yourself once you have downloaded the package, I’ll just explain some bits and pieces of the things that you’ll find in the package.
First of all, open up jc.php from the package you just downloaded, this is the file that contains the HTML codes for the gallery itself. Now start paying attention from the 7th line, you’ll see something like this:
<link rel=”stylesheet” type=”text/css” href=”style.css” />
This is the part where you call the CSS file (included in the package), you’ll need it to change/set the look of your jCarousel Lite image scroller.
Moving on to the the next part, 8th and 9th line to be specific, you’ll see two lines like the following:
<script type=”text/javascript” src=”js/jquery.js”></script>
<script type=”text/javascript” src=”js/jcarousellite.js”></script>
This is the part that calls both the jQuery library and the jCarousel Lite javascript file to execute the rest of the HTML, so don’t mess them up, be careful when you put in the the path.
Now, take a look at the most crucial part, do you see something like this?
<script>
$(document).ready(function() {
$(”.widget_style”).jCarouselLite({
btnPrev: “.previous”,
btnNext: “.next”,
/*this makes it a true carousel rather than a slideshow*/
circular: true
});
});
</script>
This is the part where the official jCarousel Lite Documentation gets the non-tech guys really confused, even though they thoroughly explain the options, they don’t explain how they can be used in an HTML file, and it doesn’t tell you that you need to put $(document)…………..}); within a <script> tag to make things work. Anyway, notice the .widget_style part on the 3rd line? It’s the CSS class we’ll be using to style the scroller, the next two lines also sets the CSS class for the previous and next button, so don’t mix them up. Moving on to the 7th line, I’ve used circular option to make it a true Carousel, this means, if you click “next” after you reach the last element, you will automatically slide to the first element and vice versa. kappish?
Let’s talk about the easier part now:
<div class=”widget”>
<a href=”#” class=”previous”></a>
<div class=”widget_style”>
<ul>
<li><img src=”http://proclubbd.com/pix/1.jpg” alt=”image 1″></li>
<li><img src=”http://proclubbd.com/pix/2.jpg” alt=”image 2″></li>
<li><img src=”http://proclubbd.com/pix/5.jpg” alt=”image 3″></li>
<li><img src=”http://proclubbd.com/pix/4.jpg” alt=”image 4″></li>
</ul>
</div><a href=”#” class=”next”></a>
</div>
Here’s where you setup the gallery itself and add/remove the images. I’ve used 4 images, but you can use as many as you like. Oh, notice the second line from both the top and the bottom? These are for the previous and next buttons.
CSS Styling
Open up the style.css file from the download package, if it hasn’t got corrupted during download, you’ll see the following codes in it. I haven’t tested the codes on all browsers, but you’ll get the idea. Let me just comment out the CSS classes so that you understand which part does what.
/*Class to set the width for the whole Carousel. You can set the width and height as you want */
.widget {
width:419px;
}/*Class to set the styling option for the previous button on the Carousel */
.widget a.previous{
float:left;
display:block;
background:url(images/prev.jpg) bottom;
width:34px;
height:34px;
margin-top:28px;
margin-right:2px;
}/*Class to set the styling option for the next button on the Carousel */
.widget a.next{
float:right;
display:block;
background:url(images/next.jpg) bottom;
width:34px;
height:34px;
margin-top:-71px;
}/*Class to set the styling option for the scroller part of the Carousel */
.widget_style {
text-align:left;
padding:0px 0px 0px 0px;
}.widget_style ul {
margin:0;
padding:0;
}/*Class to set the image background and the size of it, do note that it’s not the size of the scrolling images, it sets the size of the background image that I’ve used for every actual image that will be scrolling*/
.widget_style li {
height:89px;
width:109px;
background:url(images/imgbg.jpg) left top no-repeat;
list-style:none;
margin:0;
padding:10px 0px 0px 10px;
}/*This here actually sets the size of the scrolling images */
.widget_style img {
width:90px;
height:70px;
}
Care to look at the outcome? Click Here.
Popular Posts
All Categories
Recent Works
Search/Socialize
Recent Posts
Blogroll





This is exactly what I expected to find out after reading the title style jCarousel Lite . Thanks for informative article
A very very good article - I wished I found this first before spending 2 hours trying to make the example work!
I’m glad it helped you Marc
Hi, thanks for this - I too discovered it too late. Would have saved me a lot of hassle.
I wonder if you could help me with an additional issue. I want to dynamically update text in a div below the carousel.
I have it working at the moment where it will change the text when the picture moves but I want to show different text for each picture. Is this possible, or will I have to use the full JCarousel? I’ve included my code below.
Thanks,
Paul
Untitled Document
$(document).ready(function(){
$(function() {
$(”.anyClass”).jCarouselLite({
btnNext: “.next”,
btnPrev: “.prev”,
speed: 400,
visible: 3,
afterEnd: function(a) {
jQuery(”#infobox”).html(’my text’);
}
});
});
});
<<
>>
test
Hmm, code didn’t show properly - sorry.
Could you post a link to your site Paul?
is there anyway of only having one image on display inside the plugin instead of 3?
@Noah: Nope, I don’t think there’s any. But I don’t suppose it’s impossible
HI, really good tut. I’ve got no experience, just playing about. Got 2 quick questions:
1. How do you increase the width of the display area? I’d like it to be 590px exact.
2. If the pics are going to be links, how do you include the css styling.
As i said, great tut.
regards
Hi, great tut. Was wondering, how do you increase the display area and if the pics are links, how do you style them. I’d like to include a caption above the pic and a caption below the link.
Thanx
@mj: 1. Open up the CSS file, replace the width of the widget class with 590px.
2. Just google “how to style image links” or something and you’ll get the answer very easily.
Thank You
is there anyway of having ore than 3 images on display?
@Dorotek: Don’t think so mate.
nice tutorial..well explained
How do we integrate this plugin in wordpress
@Rajini: I haven’t tried it, but you can try Googling. Here’s a good lead: http://francisshanahan.com/www/index.php/2009/how-to-add-jcarousel-lite-to-wordpress/
Yay finally someone explained this, i dont’ understand why they don’t finish there instructions on the main website…
@Noah, @dorotek, @r_shahin:
On the jCarousel Lite documentation page (http://www.gmarwaha.com/jquery/jcarousellite/#doc), the “visible” option in the .js file sets how many items (images, in the example above) are viewable at once. The default is 3, but it can be set to another number, including fractions (i.e., 3.5).
Thanks for the tutorial!
Thank you for this. I should have found this sooner.
Hi!
How can I add 2 Jcarousels on the same page?
Excellent help. I really appreciate your post because I get up and working my page in minutes. Thanks for the easy example. Glod Bless.
wow… i am a code newbie. other page i couldnt figure out at all. your tutorial was perfect. thanks!!!! thanks for making the world a better place!
Hi the download example does not seem to work, can you send me the files?
regards
Steve
@Steve: Sorry for the inconvenience Steve, I’m in between hosts at this moment, the downloads will start working properly in a couple of days.
Thank you~
um…..
did anybody else have trouble unzipping the jc.zip archive? I can’t open it on my mac…