Quantcast
Channel: Clain Dsilva – Clain Dsilva's Blog
Viewing all articles
Browse latest Browse all 13

Pure JavaScript SlideShow

$
0
0

pure javascript slide showI have been always fascinated about the slideshows, how do they make one. Well here is the basic slideshow with pure JavaScript. No frameworks are used, No chunks of codes,  Simple Slideshow with 100% pure home grown JavaScript.

Demo Download Code

Lets start with the HTML.

<div id="show">
<div id="slideHolder">
<img src="images/slide1.jpg" />
<img src="images/slide2.jpg" />
<img src="images/slide3.jpg" />
<img src="images/slide4.jpg" />
</div>
</div>

 

  • div “show ” – this is where the images are displayed [ fixed width/ height, overflow hidden]
  • div “slideHolder” – is the div that holds the slides [relative to “show”, images float left]

Here is the CSS

#show{
width:800px;
height:250px;
border:8px solid #E9E9E9;
margin:5px auto;
overflow:hidden;
box-shadow:2px 2px 5px #514F4F;
}
#slideHolder{
width:3200px;
position:relative;
}
#slideHolder img{
float:left;
}

 

Slide Concept

Use the margin left property to move the slideHolder div inwards show div.  The overflowing part is hidden by the css. A timer function is used to iteratively reduce the margin left , lets call the function as slider(). A function named revert() is used to revert back the margins to its original position.

read more


Viewing all articles
Browse latest Browse all 13

Trending Articles