We will build a custom gallery that scans a folder of images and outputs a cool image gallery, utilizing asp.net, CSS, jQuery and the lightBox plug-in.
Demo: A Cool jQuery Gallery
Download: down
1 2 3 4 5 | <link rel="stylesheet" type="text/css" href="lightbox/css/jquery.lightbox-0.5.css" /> <link rel="stylesheet" type="text/css" href="demo.css" /> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript" src="lightbox/js/jquery.lightbox-0.5.pack.js"></script> <script type="text/javascript" src="script.js"></script> |
The demo.css is:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | .clear{ clear:both; } a, a:visited { color:#00BBFF; text-decoration:none; outline:none; } a:hover{ text-decoration:underline; } #container{ width:890px; margin:20px auto; } div.nomargin{ margin-right:0px; } .pic{ float:left; margin:0 15px 15px 0; border:5px solid white; width:200px; height:250px; } .pic a{ width:200px; height:250px; text-indent:-99999px; display:block; } h1{ font-size:28px; font-weight:bold; font-family:"Trebuchet MS",Arial, Helvetica, sans-serif; } h2{ font-weight:normal; font-size:14px; color:white; } |
the html is:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | <div id="gallery"> <div class="pic " style="background:url(gallery/ladybug.jpg) no-repeat 50% 50%;"> <a href="gallery/ladybug.jpg" title="ladybug" target="_blank">ladybug</a> </div> <div class="pic " style="background:url(gallery/bw.jpg) no-repeat 50% 50%;"> <a href="gallery/bw.jpg" title="bw" target="_blank">bw</a> </div> <div class="pic " style="background:url(gallery/bw-lingere.jpg) no-repeat 50% 50%;"> <a href="gallery/bw-lingere.jpg" title="bw-lingere" target="_blank">bw-lingere</a> </div> <div class="pic nomargin" style="background:url(gallery/red-head.jpg) no-repeat 50% 50%;"> <a href="gallery/red-head.jpg" title="red-head" target="_blank">red-head</a> </div> <div class="pic " style="background:url(gallery/wedding_catwalk.jpg) no-repeat 50% 50%;"> <a href="gallery/wedding_catwalk.jpg" title="wedding_catwalk" target="_blank">wedding_catwalk</a> </div> <div class="pic " style="background:url(gallery/tiger.jpg) no-repeat 50% 50%;"> <a href="gallery/tiger.jpg" title="tiger" target="_blank">tiger</a> </div> <div class="pic " style="background:url(gallery/lonely-anguish.jpg) no-repeat 50% 50%;"> <a href="gallery/lonely-anguish.jpg" title="lonely-anguish" target="_blank">lonely-anguish</a> </div> <div class="pic nomargin" style="background:url(gallery/promotion.jpg) no-repeat 50% 50%;"> <a href="gallery/promotion.jpg" title="promotion" target="_blank">promotion</a> </div> <div class="pic " style="background:url(gallery/pristine-lake.jpg) no-repeat 50% 50%;"> <a href="gallery/pristine-lake.jpg" title="pristine-lake" target="_blank">pristine-lake</a> </div> <div class="pic " style="background:url(gallery/tattoo.jpg) no-repeat 50% 50%;"> <a href="gallery/tattoo.jpg" title="tattoo" target="_blank">tattoo</a> </div> <div class="pic " style="background:url(gallery/white-stallion.jpg) no-repeat 50% 50%;"> <a href="gallery/white-stallion.jpg" title="white-stallion" target="_blank">white-stallion</a> </div> <div class="pic nomargin" style="background:url(gallery/furry-feline.jpg) no-repeat 50% 50%;"> <a href="gallery/furry-feline.jpg" title="furry-feline" target="_blank">furry-feline</a> </div><div class="clear"></div> </div> |
the script.js is:
1 2 3 4 5 6 7 8 9 10 11 12 | $(document).ready(function(){ $('.pic a').lightBox({ imageLoading: 'lightbox/images/loading.gif', imageBtnClose: 'lightbox/images/close.gif', imageBtnPrev: 'lightbox/images/prev.gif', imageBtnNext: 'lightbox/images/next.gif' }); }); |


