Filterable Image Gallery with preview using HTML, CSS, and Javascript

Ashutosh Tiwari
2 min readMar 30, 2022

--

Hello friends, today in this blog you will learn how to create a filterable gallery with a preview using HTML, CSS, and Javascript. In our previous blog, we saw how to detect user location using Javascript. Now it’s time to create a filterable image gallery. I’ve also shared many projects related to Javascript. So don’t forget to check here.

In this design [Filterable Image Gallery], there are some image category buttons. when you hover on the button, its background color changes into red color and the text color changes into white. When you hover over the images it increases their size and when you click on the image its preview opens in a modal.

You may like these:

The concept of filtering images using Javascript is that on buttons there is a data attribute [data-filterItem=””] in the data attribute the category of images is given and same with images there is a data attribute [data-filterName=””] when you click on the button it takes the button category name and then it takes image names and searches for matching images with that category and add a [show] class on the matching images and the images which are not matching it adds [hide] class.

If you are filling difficulty understanding what am I trying to say, So you can check the source code and preview as well.

Preview is available here:

https://incoderweb.blogspot.com/2022/03/filterable-image-gallery-with-preview.html

--

--

No responses yet