简体   繁体   English

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

[英]expanding container to content missing the 1%

im currently working on this site: 我目前在该网站上工作:

http://dingwangbag.com/ http://dingwangbag.com/

Unfortunately i still have a problem with the slideshow: most browsers seem ok by now ( sometimes still a little flicker at the end but it shows up ) 不幸的是,我仍然对幻灯片有问题:到目前为止,大多数浏览器似乎还不错(有时最后仍然有些闪烁,但显示出来了)

my HTML setup is like this 我的HTML设置是这样的

<content>

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

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

</content>

on document.ready a function is called that runs this block of code for every image after it has been fully loaded (basically getting the width of every image and adding it to the container width) 在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.
                        });
          }
};

and this block is runs on resize 这个块在调整大小时运行

(".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);

simple right 简单的权利

its workin so far but it seems to me that the scaling of the images result in some odd numbers wich sum up to a value that might be 1 or 2 px short resulting in the last container not beeing positioned properly (all containers and images are floated left) NOW where are these off numbers come from and how can i fix it ( i added 2px to the container width did help ) 到目前为止,它的工作仍然有效,但是在我看来,图像的缩放会导致一些奇数加总到一个可能短1或2 px的值,从而导致最后一个容器没有正确定位(所有容器和图像都处于浮动状态)左)现在这些折扣数字从何而来以及如何解决(我在容器宽度中添加了2px确实有所帮助)

BUT

internet explorer 9 is doing something really special by being somewhat reactive to scrolling and the mouse position randomly showing or hiding images (even within the group) SOB Internet Explorer 9通过对滚动以及鼠标位置随机显示或隐藏图像(甚至在组内) SOB有所反应,从而在做一些非常特别的事情

and i swear i have no hover or scroll functionality accociated with this in any way 我发誓我没有任何与此相关的悬停或滚动功能

so if anyone could have a look at it and hopefully help me this would be great 所以如果有人可以看看并希望对我有帮助,那就太好了

thanks in advance 提前致谢

Don't ceil it. 不要ceil

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

Also: you should update jQuery to 1.11.1 There have been bugs in the versions before. 另外:您应该将jQuery更新到1.11.1之前的版本中存在错误。

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

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