PBS KIDS Carousel

The KIDS Carousel is a simple, lightweight feature rotator plugin for jQuery.

Demos

Go Back | Go Forward

Lorem Ipsum

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Sit Dolor

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam quis lacus sed enim rutrum fringilla. Maecenas euismod purus arcu, aliquam ultricies mauris. Phasellus scelerisque, urna sit amet tincidunt ornare, sem elit aliquam nibh, ut malesuada tellus sapien at lectus. Cras rhoncus porta urna, et malesuada neque vestibulum a. Nunc at orci eros. Mauris molestie, nisl ut elementum cursus, lorem enim scelerisque ligula, non rhoncus augue arcu id massa. Aliquam imperdiet odio sit amet metus condimentum ut aliquet lacus mattis. Donec nec facilisis nunc.

Amat Mi

Phasellus dictum tempus purus non vulputate. Maecenas commodo luctus nulla, bibendum faucibus magna tristique nec. Curabitur metus quam, eleifend ut molestie id, pulvinar id erat. Mauris aliquet vestibulum rutrum. Maecenas ultricies, sapien ac porta congue, augue lorem imperdiet elit, ut sollicitudin est quam ut felis. Vivamus interdum urna eu turpis facilisis ultrices interdum mauris interdum. Vestibulum sed leo sed nisl vestibulum commodo ut a libero.

Este Sum

Integer leo augue, malesuada eget tincidunt at, cursus sit amet lacus. Phasellus ultrices ligula eu est convallis in condimentum tortor dictum. Nulla fermentum ipsum nec mi lobortis aliquam.

Final Div

Phasellus id ante faucibus risus aliquam ornare ac in est. Integer et libero neque. Nunc dignissim ultricies quam, eget sodales nisi accumsan in. Aenean volutpat, nibh non egestas suscipit, dolor nisi lobortis enim, sit amet congue dolor nisi eget eros. Vestibulum imperdiet convallis molestie. Cras eu turpis sit amet metus fermentum mollis at ac libero. Nulla facilisi. Nulla facilisi.

Lorem Ipsum

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Sit Dolor

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam quis lacus sed enim rutrum fringilla. Maecenas euismod purus arcu, aliquam ultricies mauris. Phasellus scelerisque, urna sit amet tincidunt ornare, sem elit aliquam nibh, ut malesuada tellus sapien at lectus. Cras rhoncus porta urna, et malesuada neque vestibulum a. Nunc at orci eros. Mauris molestie, nisl ut elementum cursus, lorem enim scelerisque ligula, non rhoncus augue arcu id massa. Aliquam imperdiet odio sit amet metus condimentum ut aliquet lacus mattis. Donec nec facilisis nunc.

Amat Mi

Phasellus dictum tempus purus non vulputate. Maecenas commodo luctus nulla, bibendum faucibus magna tristique nec. Curabitur metus quam, eleifend ut molestie id, pulvinar id erat. Mauris aliquet vestibulum rutrum. Maecenas ultricies, sapien ac porta congue, augue lorem imperdiet elit, ut sollicitudin est quam ut felis. Vivamus interdum urna eu turpis facilisis ultrices interdum mauris interdum. Vestibulum sed leo sed nisl vestibulum commodo ut a libero.

Este Sum

Integer leo augue, malesuada eget tincidunt at, cursus sit amet lacus. Phasellus ultrices ligula eu est convallis in condimentum tortor dictum. Nulla fermentum ipsum nec mi lobortis aliquam.

Final Div

Phasellus id ante faucibus risus aliquam ornare ac in est. Integer et libero neque. Nunc dignissim ultricies quam, eget sodales nisi accumsan in. Aenean volutpat, nibh non egestas suscipit, dolor nisi lobortis enim, sit amet congue dolor nisi eget eros. Vestibulum imperdiet convallis molestie. Cras eu turpis sit amet metus fermentum mollis at ac libero. Nulla facilisi. Nulla facilisi.

Lorem Ipsum

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Sit Dolor

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam quis lacus sed enim rutrum fringilla. Maecenas euismod purus arcu, aliquam ultricies mauris. Phasellus scelerisque, urna sit amet tincidunt ornare, sem elit aliquam nibh, ut malesuada tellus sapien at lectus. Cras rhoncus porta urna, et malesuada neque vestibulum a. Nunc at orci eros. Mauris molestie, nisl ut elementum cursus, lorem enim scelerisque ligula, non rhoncus augue arcu id massa. Aliquam imperdiet odio sit amet metus condimentum ut aliquet lacus mattis. Donec nec facilisis nunc.

Amat Mi

Phasellus dictum tempus purus non vulputate. Maecenas commodo luctus nulla, bibendum faucibus magna tristique nec. Curabitur metus quam, eleifend ut molestie id, pulvinar id erat. Mauris aliquet vestibulum rutrum. Maecenas ultricies, sapien ac porta congue, augue lorem imperdiet elit, ut sollicitudin est quam ut felis. Vivamus interdum urna eu turpis facilisis ultrices interdum mauris interdum. Vestibulum sed leo sed nisl vestibulum commodo ut a libero.

Este Sum

Integer leo augue, malesuada eget tincidunt at, cursus sit amet lacus. Phasellus ultrices ligula eu est convallis in condimentum tortor dictum. Nulla fermentum ipsum nec mi lobortis aliquam.

Final Div

Phasellus id ante faucibus risus aliquam ornare ac in est. Integer et libero neque. Nunc dignissim ultricies quam, eget sodales nisi accumsan in. Aenean volutpat, nibh non egestas suscipit, dolor nisi lobortis enim, sit amet congue dolor nisi eget eros. Vestibulum imperdiet convallis molestie. Cras eu turpis sit amet metus fermentum mollis at ac libero. Nulla facilisi. Nulla facilisi.

Download

Grab the script:

What It Does

The PBS KIDS Carousel turns a set of div panels into a rotating carousel that can be used for features, images, or anything else on a webpage. It gracefully degrades if the user does not have javascript enabled. (Try it!) It sets its own height based on the tallest panel in your list. It also dynamically generates a navigation bar with the titles of your panels as links. The time delay between rotation is customizable. By default, it begins with a random panel from your list, but you can set it to always begin with the first panel.

The Carousel requires jQuery.

Some things that make kidsCarousel special:

There are some pretty outstanding alternatives out there if this doesn’t meet your needs.

I’m happy to add to this list if others have recommendations.

Usage

Includes

  1. Include jQuery in the <head> section of your page:

    <script type="text/javascript" src="http://ajax.googleapis.com/
    ajax/libs/jquery/1.3.2/jquery.min.js"></script>
  2. Include the kidsCarousel plugin after including jQuery in the <head> section of your page:

    <script type="text/javascript" src="/includes/javascript/jquery.kidscarousel.js"></script>

    If you’re working on the PBS KIDS site, that’s all you need. If you’re using this elsewhere, please grab the script and host it on your own site, changing the directory of the include accordingly.

Markup

All the Carousel script needs is an element with a series of divs inside it to serve as panels.

<div id="myCarousel">
    <-- Panel 1 -->
    <div>
        <h4>Panel Title</h4>
        <p>Panel contents. Can be anything.</p>
    </div>
    <-- Panel 2 -->
    <div>
        <h4>Panel Title</h4>
        <p>Panel contents. Can be anything.</p>
    </div>
    <-- Panel 3 -->
    <div>
        <h4>Panel Title</h4>
        <p>Panel contents. Can be anything.</p>
    </div>
    <-- Panel 4 -->
    <div>
        <h4>Panel Title</h4>
        <p>Panel contents. Can be anything.</p>
    </div>
</div>

Initialization

The carousel needs to be initiated by running the kidsCarousel function. The simplest way is to put the following script after the other javascript includes in your <head>.

<script type="text/javascript">
$(document).ready(function() {
    $('#myCarousel').kidsCarousel();
});
</script>

The $(document).ready function intializes the script once the DOM is ready to be manipulated. The $('') selector uses CSS-style selection to target the appropriate element. You should substitute this with the #id of your own element.

CSS

The Carousel does not have any essential CSS, but you will want to add some styling for the navigation bar at the very least. This is the CSS used in the demo:

/* Each div inside your carousel is given a panel class that can be used for styling */
#myCarousel .panel h4 { margin: 0 0 1em; }

/* Styling for navigation bar */
.kidsCarouselNavigation {
    background: #333;
    font-family: Verdana, Geneva, sans-serif;
    font-size: 10px;
    margin: 10px 0 0;
    padding: 10px;
}

/* Styling for navigation bar links */
.kidsCarouselNavigation a {
    color: #fff;
    outline: none;
    padding: 5px;
    text-decoration: none;
}

/* Styling for the back and forward buttons */
.kidsCarouselNavigation .back { }
.kidsCarouselNavigation .forward { float: right !important; }

/* Styling for the navigation link that is currently displayed */
.kidsCarouselNavigation a.current { background: #666; }

Customization

There are a number of behaviors that can be customized. You can insert options by adding this to your initialization:

<script type="text/javascript">
$(document).ready(function() {
    $('#myCarousel').kidsCarousel({
        'delay' : 10000,
        'randomStart' : false,
        'relativeNavButtons' : ['Previous', 'Next']
    });
});
</script>

Options may be added in any order, and only those that you wish to change from the defaults need be added.

These are the options available, with the default option listed in bold:


This documentation is a first draft. Please let me know how it can be improved, or if you have any questions.

Nate Eagle