简体   繁体   English

在chrome的底部留下空间

[英]leaves space at the bottom on chrome

This is a responsive design and transform: translateY(2000px); 这是一个响应式设计和转换:translateY(2000px); has been applied on the blocks at the bottom. 已应用于底部的块。 The animation is working fine in Chrome, but the animation seems to leave a blank space at the bottom of the page. 动画在Chrome中工作正常,但动画似乎在页面底部留下了空白区域。 This happens only in Chrome. 这只发生在Chrome中。

Project Link: 项目链接:

http://50.87.144.37/~projtest/team/design/Call/

CSS: CSS:

.come-in {
  transform: translateY(2000px);
  -webkit-transform: translateY(2000px);
  animation: come-in 0.8s ease forwards;
  -webkit-animation: come-in 0.8s ease forwards;
}

.come-in:nth-child(odd) {
  animation-duration: 0.6s; /* So they look staggered */
  -webkit-animation-duration: 0.6s; 
}

JS: JS:

 (function($) {

      $.fn.visible = function(partial) {

      var $t            = $(this),
          $w            = $(window),
          viewTop       = $w.scrollTop(),
          viewBottom    = viewTop + $w.height(),
          _top          = $t.offset().top,
          _bottom       = _top + $t.height(),
          compareTop    = partial === true ? _bottom : _top,
          compareBottom = partial === true ? _top : _bottom;

    return ((compareBottom <= viewBottom) && (compareTop >= viewTop));

      };

    })(jQuery);

    $(window).scroll(function(d){

       $(".unWcalls").each(function(i, el) {
       var el = $(el);
    if (el.visible(true)) {
       el.addClass("come-in"); 
    } 
  });
});

The problem is that you push the elements down with translateY(2000px) and then pull them straight back up with translate(0px) . 问题是你用translateY(2000px)向下推动元素,然后用translate(0px)将它们直接拉回来。 Chrome therefore leaves a place for them at the bottom if that makes sense. 因此,如果有意义,Chrome会在底部留下一个位置。 This jsFiddle demonstrates the problem. 这个jsFiddle证明了这个问题。 (I didn't bother with all the vendor prefixes). (我没有打扰所有的供应商前缀)。

Instead, translate them down by default and pull them up on scroll, like so . 相反,默认情况下将它们翻译下来并将其拉出来, 就像这样

If it still prooves buggy, animate margin-top or top on absolute position . 如果它仍然可以证明有缺陷,可以在绝对位置设置上边距顶部 Translate doesn't affect page layout as much and is better for performance, but that's part of your problem, right? 翻译不会影响页面布局,并且性能更好,但这是您问题的一部分,对吧?

on a different note, a few issues I found: 另外,我发现了一些问题:

  1. The performance of your javascript here would be terrible. 你的javascript在这里表现会很糟糕。 Every time the user scrolls up or down, even after all the animations are completed, you run this function to check the position. 每次用户向上或向下滚动时,即使完成所有动画,也可以运行此功能来检查位置。 I'm sure you can refactor it a lot. 我相信你可以很多重构它。
  2. You have to also consider users with javascript disabled. 您还必须考虑禁用javascript的用户。 Currently there's nothing presented on the page. 目前页面上没有任何内容。
  3. I think there's a min width set on your search box and it jots out of it's border on narrow screens. 我认为你的搜索框上设置了一个最小宽度,它在狭窄的屏幕上显示出它的边框。

You can try below code: 你可以尝试下面的代码:

Change position relative to static and check may be it will work fine. 相对于静态更改位置并检查可能会正常工作。

.sitewid {
    margin: 0 auto;
    position: static;
    width: 960px;
}

Good Luck.... 祝好运....

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

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