繁体   English   中英

将容器扩展到缺少1%的内容

[英]expanding container to content missing the 1%

我目前在该网站上工作:

http://dingwangbag.com/

不幸的是,我仍然对幻灯片有问题:到目前为止,大多数浏览器似乎还不错(有时最后仍然有些闪烁,但显示出来了)

我的HTML设置是这样的

<content>

    <gallery_item>
        <image>
        <image>
        <image>
    <gallery_item>

    <gallery_item>
        <image>
        <image>
        <image>
    <gallery_item>

</content>

在document.ready上,将调用一个函数,该函数将在完全加载每个图像后为每个图像运行此代码块(基本上获取每个图像的宽度并将其添加到容器宽度)

function show_image(image){

          var $item = $(image.img);
          img_width = Math.ceil(parseInt($item.width()));

          gallery_width += img_width;       
          $("#content").width(gallery_width);

          if(images_loaded === false){
                 $item.css("opacity",0);
                 $item.removeClass('offscreen');

                 $item.animate().animate({
                        opacity: 1
                        }, 2000, function() {
                        // Animation complete.
                        });
          }
};

这个块在调整大小时运行

(".gallery_slides").each(function(i){
          current_slide_item = $(this);
          current_slide_item_width = 0; 

          $(this).find("img").each(function(){
             current_slide_item_width += $(this).width();    
          });

          gallery_width += current_slide_item_width;       
   });

   $(".gallery #content").width(gallery_width);

简单的权利

到目前为止,它的工作仍然有效,但是在我看来,图像的缩放会导致一些奇数加总到一个可能短1或2 px的值,从而导致最后一个容器没有正确定位(所有容器和图像都处于浮动状态)左)现在这些折扣数字从何而来以及如何解决(我在容器宽度中添加了2px确实有所帮助)

Internet Explorer 9通过对滚动以及鼠标位置随机显示或隐藏图像(甚至在组内) SOB有所反应,从而在做一些非常特别的事情

我发誓我没有任何与此相关的悬停或滚动功能

所以如果有人可以看看并希望对我有帮助,那就太好了

提前致谢

不要ceil

img_width = parseInt($item.width());

另外:您应该将jQuery更新到1.11.1之前的版本中存在错误。

暂无
暂无

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

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