Looking for a great responsive photo gallery with lazy load effect, then our new article is for you. During my wanderings on the internet I came across a great plugin least.js. It let you turn a set of photos into a photo gallery which works great even on mobile phones with small screens, moreover lazy load effect lets you to decrease server’s traffic. When you move your mouse over a photo, custom text is displayed. To view the full-size version – need to click on the thumb. I think that this could be ideal for you, because besides of all listed features, its size is only 1kb.
[sociallocker]
[/sociallocker]
Ok, let’s download the source files and start coding !
Step 1. HTML
In the beginning we need to link all the necessary styles and js scripts (in the header section):
2 | <link href="css/least.min.css" rel="stylesheet" type="text/css" /> |
3 | <link href="css/main.css" rel="stylesheet" type="text/css" /> |
5 | <script src="js/jquery.min.js"></script> |
6 | <script src="js/least.min.js"></script> |
7 | <script src="js/jquery.lazyload.js"></script> |
Pay attention, that the latest version of this gallery you can download here. If you want to add the support of mobile devices (small screens), you can easily add this row (in the same header section):
1 | <meta content="width=device-width, initial-scale=1" name="viewport" /> |
Now, we can prepare the main layout for our photos. Schematic structure looks like this:
03 | <li id="fullPreview"></li> |
06 | <a href="images/p1.jpg"></a> |
07 | <img data-original="images/t1.jpg" src="img/effects/white.gif" alt="Photo 1" /> |
08 | <div class="overLayer"></div> |
09 | <div class="infoLayer"> |
11 | <li><h2>Photo 1</h2></li> |
16 | <div class="projectInfo">Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.</div> |
There are 20 photos in our demo. I haven’t included all of them into our tutorial, but I hope that you understand how to add other your photos.
Step 2. CSS
Basically, all the base styles are already presented in ‘least.min.css’ which is included with the package. But I made next adjustments for our demonstration:
css/main.css
02 | background-color: #FFFFFF; |
06 | section li .overLayer, section li .infoLayer { |
10 | section li .infoLayer ul li { |
Step 3. JS
We needn’t add any special initialization code, everything works automatically.
Conclusion
Today we built the outstanding gallery which is made of HTML5 and CSS3 technologies. I hope you enjoyed our lesson. Good luck and welcome back.