CSS Image Gallery

CSS Image Gallery

HTML:

html
<!DOCTYPE html>
<html>
<head>
  <title>Image Gallery</title>
  <link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
  <div class="gallery">
    <div class="gallery-item">
      <img src="image1.jpg" alt="Image 1">
    </div>
    <div class="gallery-item">
      <img src="image2.jpg" alt="Image 2">
    </div>
    <div class="gallery-item">
      <img src="image3.jpg" alt="Image 3">
    </div>
    <!-- Add more gallery items here -->
  </div>
</body>
</html>

CSS (styles.css):

css
.gallery {
  display: flex;
  flex-wrap: wrap;
}

.gallery-item {
  flex: 1 0 200px;
  margin: 10px;
}

.gallery-item img {
  width: 100%;
  height: auto;
}

In the HTML code, you create a div with the class “gallery” to hold your gallery items. Each gallery item is represented by a div with the class “gallery-item” and an img tag inside it.

In the CSS code, we use flexbox to create a responsive gallery layout. The .gallery class applies display: flex to its children and flex-wrap: wrap to make sure the items wrap to a new line when they reach the container’s width.

The .gallery-item class specifies the width of each item using flex: 1 0 200px, which means the items will grow and shrink as necessary but will not exceed 200 pixels in width. The margin: 10px adds some spacing between the items.

The .gallery-item img class sets the width to 100% of the container to ensure the images fit within their respective gallery items while maintaining their aspect ratio.

You can add more gallery items by duplicating the <div class="gallery-item"> section and updating the src and alt attributes of the img tag with the appropriate image information.

Make sure to replace “image1.jpg”, “image2.jpg”, etc., with the actual image URLs or file paths of your images.

Feel free to customize the CSS code to fit your specific requirements, such as adjusting the dimensions, adding hover effects, or adding transitions.

Leave a Reply

Your email address will not be published. Required fields are marked *

GLOTRU Footer
Popular Features
Popular Services/

Website Development & Design

App Development & Design

Graphic Design

Digital Marketing

SEO (Search Engine Optimization)

SMM (Social Media Marketing)

Cyber Security

Company

GLOTRU Founder & CEO : __Azam

Registared : Trade,MSME,etc

Board of Director

Team

About Us

Contact Us

Privacy Policy

Return & Refund Policy

Abuse Policy

Copyright Policy

Cookie Policy

Terms & Conditions

Universal Terms of Service

Disclaimer

Legal

Sponsorships

Investor

Press Releases

Our Investments

Brands

Newsroom

Business

...

_

Digital Millennium Copyright Act
DMCA.com Protection Status

_

Content similarity detection
Protected by Copyscape

_

***ANTI-PIRACY WARNING***

...................................................................................

Follow Us :

...................................................................................

SECURE SERVER : [Legal] [Privacy Policy] [Universal Terms of Service] [Do not sell my personal information]

SITE HOSTED : GLOTRU SECURE SERVER Asian Data Centre [You can host your site][Click Here]

SSL : Server Type : [Cloudflare] Certificate Issued By : [Let's Encrypt] Signature Algorithm : [ECDSA with SHA-384]

SITE BUILD SOFTWARE : Content Management System (CMS) Softwere

_

_

_