Effect preview picture:
You can download the demo to see the complete effect. The production process is introduced below.
1. First create an html page, the html structure is as follows:
Everyone can understand at a glance that the viewer contains several pictures, ul The object contains 'previous', 'next' and navigation corresponding to each picture.
2. Next, you need to set css styles for these html elements. I won’t go into more details about css, just add styles to elements such as viewers and pictures. The viewer can only display one picture at a time:
#slider
{
width: 500px;
position: relative ;
}
#viewer
{
width: 400px;
height: 300px;
margin: auto;
position: relative;
overflow: hidden;
}
#slider ul
{
width: 350px;
margin: 0 auto;
padding: 0;
list-style-type: none;
}
#slider ul:after
{
content: ".";
visibility: hidden;
display: block;
height: 0;
clear: both;
}
#slider li
{
margin-right: 10px;
float: left;
}
#prev, #next
{
position: absolute;
top: 175px;
}
#prev
{
left: 20px;
}
#next
{
position: absolute;
right: 10px;
}
.hidden
{
display: none;
}
#slide
{
width: 2000px;
height : 300px;
position: absolute;
top: 0;
left: 0;
}
#slide img
{
float: left;
width: 400px;
height: 300px;
}
#title
{
margin: 0;
text-align: center;
}
3. Add references to jquery and jquery.easing.1.3.js to the page. Then comes the main part of our article, writing the corresponding js events for navigation.
First we need to create a new div to wrap the 5 images.
$('#viewer').wrapInner('< ;div id="slide">
'); js variable.