Simple Native Javascript Image Slider

Category: Javascript , Slider | January 14, 2014
Author:
Views Total:5,578 views
Official Page:Go to website
Last Update:January 14, 2014
License:MIT

Preview:

Simple Native Javascript Image Slider

Description:

A simple, lightweight slider based on native javascript that allows to slide through a set of images with arrows navigation and pager support.

How to use it:

Include the script.js in the page.

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

Wrap your images in a wrapper element.

<div id="slider">
<ul class="slider-list">
<li><img src="https://lorempixel.com/600/400/sports" alt=""/></li>
<li><img src="https://lorempixel.com/600/400/food" alt=""/></li>
<li><img src="https://lorempixel.com/600/400/nature" alt=""/></li>
<li><img src="https://lorempixel.com/600/400/people" alt=""/></li>
</ul>
</div>

The sample CSS to style the slider.

#slider {
width: 600px;
height: 400px;
overflow: hidden;
position: relative;
border: 3px solid #000000;
border-radius: 5px;
}
#slider ul.slider-list {
position: absolute;
left: 0;
}
#slider .slider-list li {
float: left;
width: 600px;
height: 400px;
}
#slider .prev, #slider .next {
width: 39px;
height: 50px;
position: absolute;
left: 0;
top: 0;
bottom: 0;
background: url("img/slide-arrow.png") no-repeat 0 0;
margin: auto;
text-indent: -9999px;
}
#slider .next {
left: auto;
right: 0;
background-position: 100% 0;
}
.pagination {
bottom: 0;
left: 0;
margin: auto;
position: absolute;
right: 0;
text-align: center;
}
.pagination li {
background: #000;
display: inline-block;
height: 15px;
margin: 0 3px;
width: 15px;
border-radius: 50%;
text-indent: -9999px;
box-shadow: 0 0 3px 1px #FFF;
opacity: 0.9;
cursor: pointer;
}
.pagination li.current {
opacity: 1;
box-shadow: 0 0 1px 2px #ff0000;
}

 

 

 

You Might Be Interested In:


Leave a Reply