Reputation: 1
How to make images from image gallery appear same size? (if originally they have different dimensions).
Add a description of the image here<div class="img">
<a target="_blank" href="https://unsplash.it/g/300/400">
<img src="https://unsplash.it/g/200/300" alt="Forest" width="600" height="400">
</a>
<div class="desc">Add a description of the image here</div>
</div>
<div class="img">
<a target="_blank" href="https://unsplash.it/g/400/400">
<img src="https://unsplash.it/g/400/400" alt="Northern Lights" width="600"height="400">
</a>
<div class="desc">Add a description of the image here</div>
</div>
<div class="img">
<a target="_blank" href="https://unsplash.it/g/400/400">
<img src="https://unsplash.it/g/400/400" alt="Northern Lights" width="600" height="400">
</a>
<div class="desc">Add a description of the image here</div>
</div>
<div class="img">
<a target="_blank" href="https://unsplash.it/g/400/400">
<img src="https://unsplash.it/g/400/400" alt="Northern Lights" width="600" height="400">
</a>
<div class="desc">Add a description of the image here</div>
Upvotes: 0
Views: 1077
Reputation: 2914
That depends on how you want to adjust the ones that aren't the same size. In other words, if you have a 300x200 image and a 300x300 image, you could:
These are all options you have and they'd all be implemented a little differently, so first figure out which way you want to go.
Upvotes: 0
Reputation: 3903
Update Css Add img
Class In Css. And Remove height :auto
in div.img img
Class
Note: You Can Change Hight & width in Css
img
{
width:300px;
height:200px;
}
div.img img
{
width: 100%;
}
See Live Demo Here
Snippet Example Below
div.img {
margin: 5px;
border: 1px solid #ccc;
float: left;
width: 180px;
}
div.img:hover {
border: 1px solid #777;
}
div.img img {
width: 100%;
}
div.desc {
padding: 15px;
text-align: center;
}
img
{
width:300px;
height:200px;
}
<!DOCTYPE html>
<body>
<div class="img">
<a target="_blank" href="https://unsplash.it/200/300/?random">
<img src="https://unsplash.it/200/300/?random" alt="Trolltunga Norway" >
</a>
<div class="desc">Add a description of the image here</div>
</div>
<div class="img">
<a target="_blank" href="https://unsplash.it/g/300/400">
<img src="https://unsplash.it/g/200/300" alt="Forest" >
</a>
<div class="desc">Add a description of the image here</div>
</div>
<div class="img">
<a target="_blank" href="https://unsplash.it/g/400/400">
<img src="https://unsplash.it/g/400/400" alt="Northern Lights" >
</a>
<div class="desc">Add a description of the image here</div>
</div>
<div class="img">
<a target="_blank" href="https://unsplash.it/g/400/400">
<img src="https://unsplash.it/g/400/400" alt="Northern Lights" >
</a>
<div class="desc">Add a description of the image here</div>
</div>
<div class="img">
<a target="_blank" href="https://unsplash.it/g/400/400">
<img src="https://unsplash.it/g/400/400" alt="Northern Lights" >
</a>
<div class="desc">Add a description of the image here</div>
</div>
<div class="img">
<a target="_blank" href="https://unsplash.it/g/400/400">
<img src="https://unsplash.it/g/400/400" alt="Northern Lights" >
</a>
<div class="desc">Add a description of the image here</div>
</div>
<div class="img">
<a target="_blank" href="https://unsplash.it/g/400/400">
<img src="https://unsplash.it/g/400/400" alt="Northern Lights" >
</a>
<div class="desc">Add a description of the image here</div>
</div>
Upvotes: 1