Ponerah- Image slider using HTML / CSS / Javascript, and leave a more interactive applications for the flash if needed. Slider html image will have a benefit in accordance with the SEO and also will make your site graceful.
Klik Image If You Want View DEMO
The Wireframe – HTML
Start with having a wrapping container div called main_view, and two sections nested inside called image_reel and paging. The image_reel will contain the sliding images, and paging contains the paging controls. Take a look at the image below for a visual.
<div class="main_view"> <div class="window"> <div class="image_reel"> <a href="#"><img src="reel_1.jpg" alt="" /></a> <a href="#"><img src="reel_2.jpg" alt="" /></a> <a href="#"><img src="reel_3.jpg" alt="" /></a> <a href="#"><img src="reel_4.jpg" alt="" /></a> </div> </div> <div class="paging"> <a href="#" rel="1">1</a> <a href="#" rel="2">2</a> <a href="#" rel="3">3</a> <a href="#" rel="4">4</a> </div> </div>
Styling – CSS
Take a look at the comments below for an explanation of the styles.
Setting up jQuery
For those who are not familiar with jQuery, do check out their site first and get an overview of how it works. I’ve shared a few tricks that I have picked up along the way, you can check those out as well.
Initial Step – Call the jQuery file
You can choose to download the file from the jQuery site, or you can use this one hosted on Google.
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
Directly after the line where you called your jQuery, start a new <script> tag and start your code by using the $(document).ready event. This allows your jQuery code to run the instant the DOM is ready to be manipulated. The code you will be writing in the next few steps will all take place within.
$(document).ready(function() {
//Code goes here
});
Bringing it to Life – jQuery
The following script contains comments explaining which jQuery actions are being performed.
* Setting up the Image Slider *
Start by showing the paging and activating the first link. Then we will calculate and adjust the width of the image_reel according to how many slides there are.
* Setting up the Slider Function and Timer *
We first create the function for the slide event by itself (rotate). Then create another function (rotateSwitch) that will rotate and repeat that slide event (rotate).
* Hover and Click Events *
In case the user wants to view the slide for a longer period of time, we will allow the slider to stop when it is hovered. Another thing to consider is we should reset the timer each time the paging is clicked. This will prevent unexpected slide switches and allow for a smoother experience.
//On Hover $(".image_reel a").hover(function() { clearInterval(play); //Stop the rotation }, function() { rotateSwitch(); //Resume rotation timer }); //On Click $(".paging a").click(function() { $active = $(this); //Activate the clicked paging //Reset Timer clearInterval(play); //Stop the rotation rotate(); //Trigger rotation immediately rotateSwitch(); // Resume rotation timer return false; //Prevent browser jump to link anchor });
Final !!! Good Luck
View DEMO
Credit By sohtanaka Read more »
0 comments:
Post a Comment