Slideshow is great way of displaying contents to your readers. And the use of jQuery in creating these awesome sliders or slideshows is easy to implement and modify.
Today in this tutorial we are going to create very easy Slider using Coda javascript library.
So before going to the first step you can view the working demo of tutorial and download the source code below.
Step 1: XHTML
[xml]
<div id=”content”>
<h1>Coda Slider | DEMO
&lt;div class=”wrapper”&gt;
&lt;div id=”coda-slider-1″ class=”coda-slider preload”&gt;
&lt;div class=”panel”&gt;
&lt;div class=”panel-wrapper”&gt;
<h2 class=”title”>Welcome!
&lt;p&gt;Hello, welcome to the working demo of Coda Slider. You can see how image, lists or text looks or works on various tabs. I hope you like this tutorial. Enjoy great sliding effect and try out with the above tabs.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=”panel”&gt;
&lt;div class=”panel-wrapper”&gt;
<h2 class=”title”>Images can go Like this!
<img src=”images/demo.jpg” alt=”demo image” />
Proin nec turpis eget dolor dictum lacinia. Nullam nunc magna, tincidunt eu porta in, faucibus sed magna. Suspendisse laoreet ornare ullamcorper. Nulla in tortor nibh. Pellentesque sed est vitae odio vestibulum aliquet in nec leo.
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=”panel”&gt;
&lt;div class=”panel-wrapper”&gt;
<h2 class=”title”>Recent Articles
&lt;ul&gt;
&lt;li&gt;&lt;a title=”15 Must Read Articles for Web Developers” href=”http://nikhilmisal.com/15-must-read-articles-for-web-developers/”&gt;15 Must Read Articles for Web Developers&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a title=”Why these 31 Blogs Rock (Always)?” href=”http://nikhilmisal.com/why-these-31-blogs-rock-always/”&gt;Why these 31 Blogs Rock (Always)?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a title=”30 Superbly Done Creative Ads” href=”http://nikhilmisal.com/30-superbly-done-creative-ads/”&gt;30 Superbly Done Creative Ads&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=”panel”&gt;
&lt;div class=”panel-wrapper”&gt;
<h2 class=”title”>Thank You</h2>
This tutorial is created by Nikhil Misal for Powerusers.
&lt;p&gt;Thanks for visiting this demo! If you like this tutorial then please share and comment on it.&lt;/p&gt;
&lt;p&gt;You can freely use this slider for your future projects so go ahead and download the &lt;a href=”#”&gt;Source Code&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;!– .coda-slider –&gt;
&lt;/div&gt;&lt;!– .coda-slider-wrapper –&gt;
&lt;h3&gt;&lt;a title=”Go Back to Tutorial” href=”#”&gt;Go Back to Tutorial&lt;/a&gt;&lt;/h3&gt;
Created By: Nikhil Misal
&lt;/div&gt;
[/xml]
Here the content of each slide is include in panel-wrapper and each panel is included in panel. And all these panels are included in coda-slider.
Step 2: CSS
Lets add some styling to the above file.
[css]
/*Page Styling */
body {
margin: 0;
padding: 0;
background: url(images/back.jpg);
}
#content {
width: 940px;
margin: 0 auto;
padding-bottom: 50px;
font: 1.5em Keffeesatz, Verdana, Geneva, sans-serif;
}
@font-face { font-family: Keffeesatz; src: url(fonts/YanoneKaffeesatz-Light.otf) format(“opentype”) }
@font-face { font-family: KeffeesatzBold; src: url(fonts/YanoneKaffeesatz-Bold.otf) format(“opentype”) }
h1 {
color: #ddd;
text-align: center;
padding-top: 20px;
font: 2.5em KeffeesatzBold, Verdana, Geneva, sans-serif
}
h2 {
font: 2em KeffeesatzBold, Arial, Helvetica, sans-serif;
color: #999;
text-shadow: 1px 1px 2px #000;
}
/* Coda Bar */
.coda-nav {
height: 30px;
background: #eee;
background: -webkit-gradient(
linear,
left bottom,
left top,
color-stop(0.23, #ddd),
color-stop(0.62, #eee)
);
background: -moz-linear-gradient(
center bottom,
#ddd 23%,
#eee 62%
);
width: 700px !important;
margin: 0 auto;
border: 5px solid #aaa;
border-bottom: none;
}
.coda-nav ul {
clear: both;
display: block;
margin: auto;
overflow: hidden;
}
.coda-nav ul li {
display: inline;
overflow: hidden;
}
.coda-nav ul li a {
background: url(images/button.jpg) top center no-repeat;
color: #fff;
display: block;
float: left;
margin-right: 1px;
text-decoration: none;
width: 30px;
height: 30px;
text-indent: -999px;
}
.coda-nav ul li a.current {
background: url(images/button-active.jpg) top center no-repeat;
}
.coda-nav ul li a:hover {
background: url(images/button-active.jpg) top center no-repeat;
}
/* Slider Styling */
.coda-slider {
display: block;
width: 700px;
overflow: hidden;
margin: 0 auto;
margin-bottom: 50px;
background: #eee;
background: -webkit-gradient(
linear,
left bottom,
left top,
color-stop(0.23, #ddd),
color-stop(0.62, #eee)
);
background: -moz-linear-gradient(
center bottom,
#ddd 23%,
#eee 62%
);
border: 5px solid #aaa;
border-top: none;
}
.panel-container {
position: relative;
}
.coda-slider .panel {
float: left;
width: 700px;
}
.panel-wrapper {
margin: 0 20px;
overflow: hidden;
padding: 20px 0;
}
.panel-wrapper img {
float: left;
margin: 0 20px 20px 0;
border: 5px solid #999;
}
.panel-wrapper ul li {
margin: 10px 0;
}
[/css]
We are using some CSS3 properties here. Like Gradient background and external fonts embedding @font-face. You can learn more about these properties here:
1. Speed Up with CSS3 Gradients
2. The Essential Guide to @font-face
Step 3: jQuery
[javascript]
$().ready(function() {
$(‘.coda-slider’).codaSlider({
autoHeightEaseDuration: 2500,
autoHeightEaseFunction: “easeInOutElastic”,
slideEaseDuration: 2500,
slideEaseFunction: “easeInOutElastic”
});
});
&lt;/script&gt;
[/javascript]
Add the above script in the <head> tag. This will initiate the slider operation. You can change above value and play with some functions.
I hope you like this tutorial. If you enjoyed it then please put your comments below and don’t forget to download the source code.
Enjoy the real success with testking 70-640 and 70-652 online training programs and latest HP2-Z18. Also prepare for next level with quality 000-115 dumps questions and answers of 642-654 exam.
32 Comments
Nice tut nikhil.
Thanks Akshay
🙂
oh this is great, many thanks.
good information. liked it.
Glad to see you and thanks!
Welcome to the blog… 🙂
Very cool thanks!
I have implemented a similar node slider in Drupal, using the content slider module.
A question, if I may?
Is it possible, when on item 4, when clicking item 1’s link, to make it go directly there (to item 1), rather than sliding all the way back past 3, 2 to 1? I have had a request for this in the past, and I’m not sure how to do it? Perhaps this is not what the coda slider is for, ’cause it’s a “slider”. 😉
Thanks Steve!
One thing you can do is add Previous and Next buttons so that when you are on the last slide and click Next you will get the first slide as the next slide. Its infinite carousel.
Check the following links. I hope that you will find what you are looking for.
http://css-tricks.com/anythingslider-jquery-plugin/
http://jqueryfordesigners.com/jquery-infinite-carousel/
http://www.queness.com/post/923/create-a-simple-infinite-carousel-with-jquery
thankx for the post but i need it auto….? how to do that?
this is really helpful, thanks for sharing (:
Great slider, good work on this. I’d like to add numbered tabs instead of the images and start/stop buttons (like the Anything Slider). Any ideas how I’d do this with your code?
Thanks for sharing this info.. Useful one. My blog
how do I make the slider go vertical instead of horizontal?
Coda Slider , Una implemantacion junto a background animado en nuetro proyecto web.
http://www.3notebooks.com
good post………..
i am from kerala,india
Hey this is fantastic!
I am using it for the base of a site i’m doing atm – quick question, I have been racking my brain on how to do this…I have changed the tab buttons and want to add txt to them so the user can navigate to the appropriate area. Any advice on how to change the slider nav to individually titled tabs?
Thanks,
K
how do I move the nav to the bottom of the slider?
Very nice tutorial – thanks.
Can the buttons be changed to named tabs such as “home”, “contact”, etc?
I played around with the js but can’t see how to change this.
Love the tutorial and the slider, it’s very easy to work with and edit.
Thanks,
tori
There is an issue around duplicate content and you could argue that google might smile at you if you help it out by telling it on a link by link basis not to follow certain links… e.g. paid adds and social bookmarks etc.
great slider, i really like the bouncing affects.
Hi everyone, it’s my first pay a visit at this website, and article is genuinely fruitful in favor
of me, keep up posting these content.
Hi,
Nice tutorial .
Website development company in Indore