我正在使用高級自定義字段與圖庫字段附加組件和Fancybox。如果觀衆點擊縮略圖,Fancybox幻燈片應該會彈出。問題是,縮略圖沒有顯示出來。當我檢查元素時,出於某種原因,img大小爲0x0。高級自定義字段字段圖像不顯示
這裏是我的代碼:
<div id="post-img">
<?php
$images = get_field('gallery');
$image_1 = $images[0];
?>
<?php foreach($images as $image): ?>
<a href="<?php echo $image['url']; ?>" rel="fancybox">
<h5>view images</h5><img src="<?php echo $image_1['url']; ?>"/>
</a>
<?php endforeach; ?>
</div><!-- #post-img -->
CSS:
#post-img {
float:left;
margin-bottom:0;
padding-top:10px;
padding-bottom:0;
}
#post-img a {
display:none;
}
#post-img img {
display:none;
width:200px;
height:auto;
}
#post-img a:first-of-type img{
display:block;
}
謝謝,我添加了代碼,因爲我只想顯示一個縮略圖,但後來我忘了在它後面添加'#post-img a:first-child {display:block;}'。現在它可以工作。 –