dsfdsf46465 2013-03-12 15:03
浏览 67
已采纳

Fancybox:使用背景图片

I'm having a bit of trouble with fancybox on the photo's section.

At the moment when you click on one of the images it loads the same size as on the page (the image is actually much larger) and also removes the div from the page.

I want to load the background image of the div at it's full size into the fancybox.

<div class="main-photo fancybox" rel="group" style="background-image:url('<?php echo $photo; ?>');">
   <a href="<?php echo the_sub_field('photo'); ?>">
      <img src="<?php bloginfo('stylesheet_directory'); ?>/images/picture-of-health-photo-frame.png" height="240" width="360" />
   </a>
</div>

The img within the link is actually the photo frame, which I don't want to be included within the fancybox.

  • 写回答

2条回答 默认 最新

  • doulu8847 2013-03-13 06:42
    关注

    You need to set class="fancybox" to the anchor <a> tag, not to the <div> tag so :

    <div class="main-photo" rel="group" style="background-image:url('<?php echo $photo; ?>');">
       <a class="fancybox" href="<?php echo the_sub_field('photo'); ?>">
          <img src="<?php bloginfo('stylesheet_directory'); ?>/images/picture-of-health-photo-frame.png" height="240" width="360" />
       </a>
    </div>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 evo评估时曲线出现问题
  • ¥15 eNSP拓扑图配置实验
  • ¥20 有没有兄弟会替换fmod studio的.bank文件内的音效?
  • ¥20 如何解决访问网址被屏蔽的情况
  • ¥15 本地运行的vue2项目,使用内网穿透,前端界面一直转圈圈
  • ¥20 powerbuilder datawindow控件导出Excel数据,可不可以不自动覆盖原数据,而是在后面新插入入数据。
  • ¥100 无轴承永磁同步电机控制
  • ¥15 eps里添加本地倾斜模型
  • ¥15 telegram 问题
  • ¥15 nrf52810-c三个a 程序