How do I use HTML and CSS to create a flexible solution gallery?

Hello, my name is Ankit. I’m attempting to create a website that uses a museum format to display items. I’m new to website development, and I’m not certain how to organize the HTML or use CSS to make the gallery appear both on desktop and mobile windows. Can someone please explain the best way to make a flexible, fresh item gallery?

Welcome, Ankit, and good day!

I can offer some advice, but it’s unlikely that someone these will create the site for you.

Start by learning the basics of HTML and CSS. This foundation will make everything else much easier. For a product gallery, structure your markup . You might use a

for the gallery itself, and wrap each product in a

with a

for its name or description. Then use CSS Grid or Flexbox to lay out the items and make them responsive. Relative units (%, em, rem) and will help the design adapt to different screen sizes.

ChatGPT can be a wonderful resource for beginners and to get started and give examples, but you’ll get the most out of it when you’ve learned the in-depth concepts. You’ll be able to figure out what the script does and how to modify it in that way.

There are many courses online, but here are a few references for you.

I would suggest checking out Kevin Powell’s another video.

1 Like

An illustration of a popup

I recently conducted a Google search for “lightbox no ajax.” A light box museum case was something I needed to find a ready-made script that I could use.

Simplelightbox was the first one that caught my attention.

I’m never using nodejs and prefer the code, but I did a different seek for” simplelightbox cdn,” which brought me to this website.

The two code I retrieved were written in English.
Javascript

CSS

I followed the simplelightbox page’s example.

adding primitives to putting cards and pots.

HTML

I used network and auto-fit for the CSS.

CSS

/* reset css from https://piccalil.li/blog/a-more-modern-css-reset/ */@import "https://assets.codepen.io/3351103/__modern-reset.css";body { padding: 3rem;}.container { width: 100%; max-width: 1024px; margin-inline: auto;}.cards { display: grid; /* grid auto-fit, when images shrink to 250px they break on to new lines */ grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1rem;}

The java was incredibly straightforward.

window.addEventListener('DOMContentLoaded', (event) => { // create a new instance of SimpleLightbox passing in gallery links const gallery = new SimpleLightbox('.gallery a'); })

Demo

This was accomplished fairly quickly. I would also suggest watching Kevin Powell’s video, though.:slight_smile:

1 Like

Leave a Comment