Shortcode for Gallery: [gallery link="file" columns="5" size="medium"]
I’m using a 5 column gallery on an inner page of a website, obviously when the site responds down to mobile and even tablet devices, the images within the gallery keep the default style of width: 20%;
and appear far too small.
I have tried adding a media query style to increase the width in percentage, however WP still applies the column class .gallery-columns-5
.
Ideally It would be great to have the images in 5 Columns for Desktop's, 3 Columns for Tablet's and 1 Column for Mobile Devices.
Would anyone know of a good fix for this?
/ ## Gallery
--------------------------------------------- */
.gallery {
overflow: hidden;
}
.gallery-item {
float: left;
margin: 0 0 30px;
padding: 0 5px;
text-align: center;
width: 100%;
}
.gallery-columns-5 .gallery-item {
width: 20%;
}
.gallery-columns-2 .gallery-item:nth-child(2n+1),
.gallery-columns-3 .gallery-item:nth-child(3n+1),
.gallery-columns-4 .gallery-item:nth-child(4n+1),
.gallery-columns-5 .gallery-item:nth-child(5n+1),
.gallery-columns-6 .gallery-item:nth-child(6n+1),
.gallery-columns-7 .gallery-item:nth-child(7n+1),
.gallery-columns-8 .gallery-item:nth-child(8n+1),
.gallery-columns-9 .gallery-item:nth-child(9n+1) {
clear: left;
}
.gallery img {
border: 1px solid #ddd;
height: auto;
padding: 4px;
}
.gallery img:hover {
border: 1px solid #999;
}
@media only screen and (max-width: 800px)
.gallery-item {
width: 33%;
}