Displaying a manual slideshow with W3.CSS is very easy.
Bạn đang xem: Image slideshow html code w3schools
Just create many elements with the same class name:
Then Gọi showDivs() khổng lồ display the first image.
When the user clicks one of the buttons call plusDivs().
The plusDivs() function subtracts one or adds one to the slideIndex.
The showDiv() function hides (display="none") all elements with the class name "mySlides", và displays (display="block") the element with the given slideIndex.
If the slideIndex is higher than the number of elements (x.length), the slideIndex is phối khổng lồ zero.
Xem thêm: Giải Mã Từ Khóa Pwc Là Gì
If the slideIndex is less than 1 it is set to lớn number of elements (x.length).
Add a caption text for each image slide with the w3-display-* classes (topleft, topmiddle, topright, bottomleft, bottommiddle, bottomright, left, right or middle):
An example of using buttons to indicate how many slides there are in the slideshow, & which slide the user is currently viewing.
An example of using images as indicators:
To operate multiple slideshows on one page, you must class the members of each slideshow group with different classes:
Slide or fade in an element from the top, bottom, left or right of the screen with the w3-animate-* classes.
The w3-animate-fading class fades an element in and out (takes about 10 seconds).