I am currently working on a photo gallery page where I display images of varying widths and heights. My goal is to use CSS to ensure that all the images are displayed in a uniform width and height dynamically.
While I have successfully managed to set the width dynamically, I am facing challenges with setting the image height. Currently, I manually set the height for the images and adjust them at different breakpoints using @media queries. I don't mind if some excess height is trimmed off (hidden).
@media(max-width: 1300px)
{
ul.grid-nav li {
display: block;
margin: 0 0 5px;
}
ul.grid-nav li a {
display: block;
}
ul.rig {
margin-left: 0;
}
ul.rig li {
width: 45% !important; /* over-ride all li styles */
}
.img {
height: 250px;
overflow: hidden;
}
}
Example Page
Is there any way to dynamically set the height of the .img based on the width of rig.li?
Thank you!