Difference between revisions of "Image slider"
m |
(css) |
||
Line 43: | Line 43: | ||
</div> | </div> | ||
+ | |||
+ | If you want to use the same CSS as this working example, the rules are as follows: | ||
+ | {{code|<css>/* style for next/prev links in "Image slider" page */ | ||
+ | .image-slider .is-next, .image-slider .is-prev { | ||
+ | background-color: black; | ||
+ | color: white; | ||
+ | text-decoration: none; | ||
+ | outline: 0; | ||
+ | font-size: 15px; | ||
+ | font-weight: bold; | ||
+ | -moz-border-radius: 11px; | ||
+ | -webkit-border-radius: 11px; | ||
+ | -khtml-border-radius: 11px; | ||
+ | border-radius: 11px; | ||
+ | padding: 5px 14px; | ||
+ | margin: 5px; | ||
+ | -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)"; /* IE 8 */ | ||
+ | filter: alpha(opacity=50); /* IE 5-7 */ | ||
+ | -moz-opacity: 0.5; /* Netscape */ | ||
+ | -khtml-opacity: 0.5; /* Safari 1.x */ | ||
+ | opacity: 0.5; /* Good browsers */ | ||
+ | } | ||
+ | .image-slider .is-next:hover, .image-slider .is-prev:hover { | ||
+ | text-decoration: none; | ||
+ | outline: 0; | ||
+ | -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)"; | ||
+ | filter: alpha(opacity=100); | ||
+ | -moz-opacity: 1; | ||
+ | -khtml-opacity: 1; | ||
+ | opacity: 1; | ||
+ | } | ||
+ | .image-slider .thumbs img { | ||
+ | margin: 5px 5px 0 0; | ||
+ | }</css>}} | ||
<html> | <html> | ||
<script type="text/javascript"> | <script type="text/javascript"> |
Revision as of 20:50, 31 March 2015
Here's a simple image slider written 100% in JavaScript and jQuery. In converts any div elements of class "image-slider" containing img elements into a slider like the one below. You can use your own CSS rules to give the next/prev links a nicer style and make a frame around the image. The images should all be the same size for it to work properly. The code is in our Subversion repository here.
There are two variables at the start of the code, delay and thumbWidth, these determine the time in seconds before the next image change, and the width in pixels of the thumbnail images below the sliding image. Each image slider div element can be configured to have a row of clickable thumbnail images below the sliding image by adding "thumbs" to the class attribute as in the example code following.
In the wiki you can use image links as follows:
Here's an example of a pure HTML page which has the links to the scripts and images included:
Here's a working example:
If you want to use the same CSS as this working example, the rules are as follows: