【问题标题】:Position thumbnails in fancybox在fancybox中放置缩略图
【发布时间】:2015-07-07 16:26:43
【问题描述】:

每当您以全尺寸打开窗口时,一切正常。但是,当您水平调整窗口大小时,拇指会移动并消失。我希望它像大型弹出图像一样保持原样,固定在它们的位置,以便重新调整大小的用户能够通过 y 滚动看到它们。

有什么帮助吗?

JSFIDDLE:http://jsfiddle.net/ny9ytae5/4/

HTML:

<a caption="<h2>Image Header</h2><p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.</p>" rel="Sold" class="fancybox" data-fancybox-group="thumb1" href="http://fancyapps.com/fancybox/demo/4_b.jpg"><img src="http://fancyapps.com/fancybox/demo/4_s.jpg" alt="" /></a>

        <a class="fancybox hidden" data-fancybox-group="thumb1" href="http://fancyapps.com/fancybox/demo/3_b.jpg"><img src="http://fancyapps.com/fancybox/demo/3_s.jpg" alt="" /></a>

        <a class="fancybox" data-fancybox-group="thumb2" href="http://fancyapps.com/fancybox/demo/2_b.jpg"><img src="http://fancyapps.com/fancybox/demo/2_s.jpg" alt="" /></a>

        <a class="fancybox hidden" data-fancybox-group="thumb2" href="http://fancyapps.com/fancybox/demo/1_b.jpg"><img src="http://fancyapps.com/fancybox/demo/1_s.jpg" alt="" /></a>

更新:我发现删除:

 'left': Math.floor($(window).width() * 0.5 - (obj.group.length / 2 * this.width + this.width * 0.5))

来自 jquery.fancybox-thumbs.js 解决了这个问题,但前提是浏览器以全尺寸打开。如果用户在小窗口中打开网站,缩略图甚至不会出现。

【问题讨论】:

    标签: javascript jquery html css fancybox


    【解决方案1】:

    新的、简单的解决方案:

    由于您希望缩略图不适应屏幕宽度并且不根据当前活动元素重新定位,一个非常简单的解决方案是否决属性,即jquery.fancybox-thumbs.js 脚本通过内联样式设置。

    这样你就不需要对原来的jquery.fancybox-thumbs.js做任何修改

    通过在 (!) jquery.fancybox-thumbs.css(或任何其他样式表,在 jquery.fancybox-thumbs.css 之后加载:

    /* added Rules: */
    
    #fancybox-thumbs {
       width: 920px !important;
    }
    
    #fancybox-thumbs ul {
      left: inherit !important;
      margin: 0 auto;
    }
    

    还有:瞧... updated jsfiddle


    旧解决方案

    正如您已经发现的那样,fancybox thumbnail-helper 使用$(window).width() 来获取屏幕宽度并相应地调整缩略图的位置。

    我认为您应该像这样修改本地版本的 jquery.fancybox-thumbs.js


    添加固定宽度变量

    下面:

    //Shortcut for fancyBox object
    var F = $.fancybox;
    

    添加这个:

    var fixedWidth = 920;
    

    $(window).width() 替换为fixedWidth

    这样:

    this.list.width(this.width * (obj.group.length + 1)).css('left', Math.floor($(window).width() * 0.5 - (obj.index * this.width + this.width * 0.5)));
    

    变成

    this.list.width(this.width * (obj.group.length + 1)).css('left', Math.floor(fixedWidth * 0.5 - (obj.index * this.width + this.width * 0.5)));
    

    还有这个:

    'left': Math.floor($(window).width() * 0.5 - (obj.index * this.width + this.width * 0.5))
    

    变成:

    'left': Math.floor(fixedWidth * 0.5 - (obj.index * this.width + this.width * 0.5))
    

    我目前没有时间检查它是否真的有效,但机会很高;-)

    祝你好运!

    【讨论】:

    • 这就是我想要的,但有一件事,每当我更改图像时,缩略图就会移动,有没有办法阻止它移动?
    • 如果可能,请提供最后一个问题,无论如何要修复该描述框,以便在窗口重新调整大小时用户可以使用水平滚动检查它?
    • 对此有什么帮助吗?对此stackoverflow.com/questions/30994366/… bounty:250 的任何帮助
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-01-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-28
    • 1970-01-01
    相关资源
    最近更新 更多