CSS Image Gallery

CSS பட கேலரியைக் கற்றுக்கொள்ளுங்கள்

CSS Image Gallery

ஒரு CSS பட கேலரி என்பது ஒரு வலைப்பக்கத்தில் ஒழுங்கமைக்கப்பட்ட, பெரும்பாலும் பதிலளிக்கும் வழியில் காட்டப்படும் படங்களின் தொகுப்பாகும்.

இங்கே நாம் ஒரு பட கேலரியை உருவாக்க CSS ஐப் பயன்படுத்துகிறோம்:

ஒரு பட கேலரிக்கான HTML அமைப்பு:

HTML and CSS Code

இங்கே HTML மற்றும் CSS குறியீடு உள்ளது:

Example

<html>
<head>
<style>
div.gallery {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
}

div.gallery-item {
  margin: 5px;
  border: 1px solid #ccc;
  width: 180px;
}

div.gallery-item:hover {
  border: 1px solid #777;
}

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

div.gallery-item div.desc {
  padding: 15px;
  text-align: center;
}
</style>
</head>
<body>

<div class="gallery">

<div class="gallery-item">
  <a target="_blank" href="img_5terre.jpg">
    <img src="img_5terre.jpg" alt="Landscape 1" width="600" height="400">
  </a>
  <div class="desc">Landscape 1</div>
</div>

<div class="gallery-item">
  <a target="_blank" href="img_forest.jpg">
    <img src="img_forest.jpg" alt="Landscape 2" width="600" height="400">
  </a>
  <div class="desc">Landscape 2</div>
</div>

<div class="gallery-item">
  <a target="_blank" href="img_lights.jpg">
    <img src="img_lights.jpg" alt="Landscape 3" width="600" height="400">
  </a>
  <div class="desc">Landscape 3</div>
</div>

<div class="gallery-item">
  <a target="_blank" href="img_mountains.jpg">
    <img src="img_mountains.jpg" alt="Landscape 4" width="600" height="400">
  </a>
  <div class="desc">Landscape 4</div>
</div>

</div>

</body>
</html>

💡 உதவிக்குறிப்பு:

மேலே உள்ள பட கேலரிக்கு நாங்கள் display: flex; பயன்படுத்தியுள்ளோம். வரிசைகள் அல்லது நெடுவரிசைகளில் படங்களை வரிசைப்படுத்த இந்த லேஅவுட் தொகுதி பயனுள்ளதாக இருக்கும். CSS டுடோரியலில் பின்னர் CSS Flexbox பற்றி மேலும் அறிந்து கொள்வீர்கள்.

Exercise

பட கேலரியில் படங்களை வரிசையாக வைக்க எந்த CSS பண்பு பயன்படுத்தப்படுகிறது?

display: block;
✗ தவறு!
display: flex;
✓ சரி! படங்களை வரிசையாக வைக்க display: flex; பயன்படுத்தப்படுகிறது
float: left;
✗ தவறு!
position: absolute;
✗ தவறு!