简体   繁体   English

Fancybox:使用背景图片

[英]Fancybox: using a background image

I'm having a bit of trouble with fancybox on the photo's section. 我在照片部分的fancybox遇到了一些麻烦。

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. 当您单击其中一个图像时,它会加载与页面上相同的大小(图像实际上要大得多),并且还会从页面中删除div。

I want to load the background image of the div at it's full size into the fancybox. 我想将div的完整大小的背景图像加载到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. 链接中的img实际上是相框,我不想将其包含在fancybox中。

Have you checked, with Firebug or any other inspector, that the image being loaded by Fancybox is actually the "big image" that you want? 您是否使用Firebug或任何其他检查员检查过Fancybox正在加载的图像实际上是您想要的“大图像”?

Because I have, and you are loading the exact same image. 因为我有,你正在加载完全相同的图像。 :) :)

You need to set class="fancybox" to the anchor <a> tag, not to the <div> tag so : 你需要将class="fancybox"设置为锚<a>标签,而不是<div>标签,这样:

<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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM