【问题标题】:Why lightbox doesn't work when div has a child div为什么当div有子div时灯箱不起作用
【发布时间】:2013-08-22 08:04:57
【问题描述】:

我正在使用一个灯箱插件,它使用 rel="lightbox" 在我使用高级自定义字段插件创建的图库中触发灯箱。一切都很好,直到我想添加一个绝对定位在盒子 div 中的子 div。它应该在悬停时改变不透明度并且仍然有灯箱火。

我的标记

  <?php if(get_field('image')):
    $attachment_id = get_field('image');
    $size = "full";
    $image = wp_get_attachment_image_src( $attachment_id, $size );
    $alt = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true); 
    $image_title = $attachment->post_title;
    $caption = $attachment->post_excerpt;
    ?>
    <a href="<?php echo $image[0]; ?>" rel="lightbox"><?php echo wp_get_attachment_image( $attachment_id, medium); ?>  </a>
      <div class="hover-title">
    <?php  the_field('hover_title');?>
    </div><!-- hover title -->
    <?php endif; ?>
    </div><!-- box -->

如果我只是删除“悬停标题”灯箱作品。但我想用那个:)

我的CSS: .box 一个 { 边距:5px; 向左飘浮; 位置:相对; 溢出:隐藏; 不透明度:1; 显示:块; }

【问题讨论】:

    标签: wordpress lightbox


    【解决方案1】:

    是完整的代码。如果是这样,那么你错过了一个开头&lt;div&gt;

    你的前两行应该是

    $attachment_id = get_field('image');
    if ( $attachment_id ) {
    
    }
    

    不需要调用两次get_field(),毕竟是数据库调用。

    祝你好运

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-04-15
      • 1970-01-01
      • 1970-01-01
      • 2013-04-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-07
      相关资源
      最近更新 更多