简体   繁体   English

移动滚动条上固定元件底部的透明开口

[英]Transparent opening at bottom of fixed element on mobile scroll

It's hard for me to explain this, but I currently have a fixed item at the bottom of the page, and it disappears once the user scrolls to the bottom of the site, showing another div with a large amount of text. 我很难解释这一点,但是我目前在页面底部有一个固定项目,一旦用户滚动到网站底部,它就会消失,并显示另一个包含大量文本的div。 Once the user starts scrolling back to the top of the site, the fixed element re-appears at the bottom of the screen. 用户开始滚动回到站点顶部后,固定元素将重新出现在屏幕底部。 The position of the fixed element is set to "bottom:0". 固定元素的位置设置为“ bottom:0”。

Unfortunately, sometimes, when the user scrolls up there is a transparent box about 20px in height below the fixed item. 不幸的是,有时,当用户向上滚动时,在固定项目下方会出现一个透明框,其高度约为20px。 You can see the elements on the page that would appear underneath the fixed element, but the fixed element stays on top. 您可以在页面上看到固定元素下方显示的元素,但固定元素仍位于顶部。

When I click on this blank space, the Google search bar appears. 当我单击此空白区域时,将显示Google搜索栏。 Is the Google search bar the thing that is causing the transparent box below the fixed element? Google搜索栏是否是导致固定元素下方的透明框出现的原因? What else could it be? 还有什么呢? This does not happen on Developer tools emulators, only on actual phones. 在开发人员工具仿真器上不会发生这种情况,仅在实际的电话上会发生。

Here is an image below: 这是下面的图像:

我正在经历的图片

Here is my JS: 这是我的JS:

$(".mobile-isi-expand").click( function (){
    var topMenuHeight = $('.mobile-top-menu').height();
    var documentHeight = $('#pageContent').height();
    var screenHeightSans = $(window).height();

    console.log(topMenuHeight);
    console.log(documentHeight);
    var desiredExpandedHeight = topMenuHeight;
    var desiredContractedHeight = "150px";
    var deviceHeight = $(window).height();
    var regionContent = $(".region-content").height();
    if(documentHeight === null){
        documentHeight = screenHeightSans;
    }
    else {

    }
        if($(this).hasClass("mobile-expanded")) {
            $(this).removeClass("mobile-expanded");
            $(".mobile-isi-container").animate({
                "height":"150px",
                "bottom":"0",
                "top":deviceHeight - 150
            });
        }
        else {
            $(this).removeClass("mobile-isi-minimize");
            $(".mobile-isi-expand").addClass("mobile-expanded");
            $(".mobile-isi-container").animate({
                "top":desiredExpandedHeight,
                "height": documentHeight
            });
        }
});


$(function($) {
    if(Modernizr.mq('(max-width: 480px)')) {
        $(window).on('scroll', function() {
            var is_root = location.pathname == "/";
            var referenceHeight = $('.referenceArea').height();
            var pageContentHeight = $("#pageContent").height();
            var regionContent = $(".region-content").height();
            var refAndPageHeight = referenceHeight + pageContentHeight;


            if($(this).scrollTop() >= regionContent - 220) {
                $('.mobile-hidden-isi').addClass("mobile-active");
                $('.mobile-isi-container').css({"display":"none", "height": "150px"});
            }
            else {
                $('.mobile-hidden-isi').removeClass("mobile-active");
                $('.mobile-isi-container').css({"display":"block", "height": "150px", "bottom" : "0"});
                var mobileISIheight = $('.mobile-isi-container').height();
                console.log(mobileISIheight);
            }
        })
       }
       else {

       }
});

CSS: CSS:

.mobile-isi-container {
    position: fixed;
    bottom: 0;
    font-family: 'quicksandregular';
    left: 0;
    display: block;
    background-color: #fff;
    width: 100%;
    height: 150px;
    min-height: 150px;
    z-index: 999999;
    -webkit-transition: all 0.5s ease;
    -moz-transition: all 0.5s ease;
    -o-transition: all 0.5s ease;
    transition: all 0.5s ease;
    overflow-y: scroll;
    -webkit-box-shadow: 1px -1px 3px -1px rgba(64,62,64,1);
    -moz-box-shadow: 1px -1px 3px -1px rgba(64,62,64,1);
    box-shadow: 1px -1px 3px -1px rgba(64,62,64,1);
}

this occurred due to the address bar appearing and disappearing. 发生这种情况的原因是地址栏的出现和消失。 It changes the calculated window.height(). 它将更改计算出的window.height()。 All I did was add an overflow-y: visible instea of overflow-y: scroll in my css, and added a background color. 我所做的就是添加一个y溢出:可见的instea:在我的CSS中滚动,并添加背景色。 This covers up the transparent area, though it does make the height of the fixed element sort of variable. 尽管它确实使固定元素的高度可变,但它覆盖了透明区域。

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

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