Image Viewer built with CSS + JS
This is a simple image Viewer built with CSS + Js. You can click a thumbnail to view the large image. The description of each image is displayed. The position of the large image is fixed width and height, and the excess part is hidden, click the big picture to view the full size, compatibility: IE, Firefox, and opera.
JS Section
Function showpic (whichpic ){
If (document. getelementbyid ){
Document. getelementbyid ('holder'). src = whichpic. href;
If (whichpic. Title ){
Document. getelementbyid ('desc'). childnodes [0]. nodevalue = whichpic. title;
} Else {
Document. getelementbyid ('desc'). childnodes [0]. nodevalue = whichpic. childnodes [0]. nodevalue;
} Return false;
} Else {
Return true;
}}
XHTML
<Div id = "album"> <Div id = "pic"> </ div> <p id = "DESC"> description of the first large image </P> <Div id = "thumbs"> <ul> <li> <a onclick = "Return showpic (This ); "href =" Address of the first large image "Title =" "> </a> </LI>... </ul> </div>
CSSCodeSeeArticleTerminal demo File Download
Current results
Because the position of the big image is fixed, but the size of each image is different, the running result of the above Code is not ideal. You need to click the big picture to view the full size code, here we use a good lightbox effect.
Add in the above JS Code
Document. getelementbyid ('showlightbox'). href = whichpic. href;
Lightbox needs to have a big image address in label ..
Add the lightbox code to the head area.
In the above XHTML code, add
<Div id = "pic"> <a href = "Address of the first large image" rel = "lightbox" id = "showlightbox"> </a> </div>
Final Effect
Download all Demo files
Thanks to hooline And Lokesh dhakar