我想为图库图片添加边框。但在棋盘效果中,图像1,3,5,7,9 ......将为黑色,而2,4,6,8,10 ......将为白色。
我尝试了以下CSS,但我没有运气:(
#gallery-1:nth-child(odd) img {
border: 3px solid #B8A8A8;
}
#gallery-1:nth-child(even) img {
border: 3px solid #000000;
}
.attachment-thumbnail:nth-child(odd) {
border: 3px solid #B8A8A8;
}
.attachment-thumbnail:nth-child(even) {
border: 3px solid #000000;
}
这是HTML
<dl class="gallery-item">
<dt class="gallery-icon portrait">
<a href="http://something.co.uk/ducfs/?attachment_id=9"><img width="120" height="120" src="http://something.co.uk/ducfs/wp-content/uploads/2013/11/Events-1-IMG_4864-150x150.jpg" class="attachment-thumbnail" alt="Events 1 IMG_4864"></a>
</dt></dl>
非常感谢任何帮助。谢谢!
答案 0 :(得分:2)
使用此
.gallery-item img:nth-child(odd){}
.gallery-item img:nth-child(even){}
而不是
#gallery-1:nth-child(odd) img {
border: 3px solid #B8A8A8;}
#gallery-1:nth-child(even) img {
border: 3px solid #000000;}
我认为,它可能会奏效。