库的短代码:[gallery link="file" columns="5" size="medium"]
我在一个网站的内页上使用了一个5列的图库,显然当该网站对移动设备甚至平板设备做出响应时,图库中的图像会保持默认的样式width: 20%;
看起来太小了。
我尝试添加媒体查询样式以增加百分比宽度,但WP仍然应用列类.gallery-columns-5
.
理想情况下,桌面上有5列图像,平板电脑有3列,移动设备有1列。
有谁知道有什么好办法吗?
/ ## 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%;
}