简体   繁体   English

底部神秘的白色条纹 Safari iOS

[英]Mystical white stripe at bottom on Safari iOS

I have a website where an unwanted white stripe is appearing at the very bottom, and this only for mobile Safari iOS visitors.我有一个网站,在最底部出现了一条不需要的白色条纹,这仅适用于移动 Safari iOS 访问者。

I'm using the following code for the footer area to stick it to the bottom:我在页脚区域使用以下代码将其固定在底部:

<div class="page_wrapper">
    <!-- Content here -->
</div>
<div id="footer">
    <div class="footer_sticker">    
        <div class="footer_upper">
            <!-- Content here -->
        </div>
        <div class="footer_lower">
            <!-- Content here -->
        </div>
    </div>
</div>



#footer, .page_wrapper:after {
    height: 275px;
}
.page_wrapper:after {
    content: "";
    display: block;
}
.page_wrapper {
    margin-bottom: -275px;
    min-height: 100%;
}
#footer {
    position: relative;
}
#footer .footer_sticker {
    bottom: 0;
    height: 275px;
    position: absolute;
    width: 100%;
}

Question from bygone era but, I encountered the issue today, when changing the view from portrait orientation to landscape.来自过去时代的问题,但是,我今天遇到了这个问题,将视图从纵向更改为横向。 So here's my solution:所以这是我的解决方案:

My Research:我的研究:

NOTICE: When changing from portrait to landscape - the address-bar is hidden and when you change back to portrait (from landscape) the address-bar appears slowly (takes a split sec).注意:当从纵向更改为横向时 - address-bar是隐藏的,当您更改回纵向(从横向)时, address-bar缓慢出现(需要一秒钟)。 THAT'S THE PROBLEM!这就是问题所在! . .

You see, that magical white strip at the bottom is almost the same height as address-bar + mobile top bar你看,底部那个神奇的白条和address-bar + mobile top bar几乎一样高

Basically CSS height: 100%/100vh is painted before all those magic happens and we get that annoying blank white bar at the bottom.基本上 CSS height: 100%/100vh是在所有这些魔法发生之前绘制的,我们会在底部看到令人讨厌的空白白条。

How I solved我是怎么解决的

By calculating the height of the document in a delay (of say 200ms) so I can get the final height of the document after all the effects and set the document height with the new value.通过延迟(比如 200 毫秒)计算文档的高度,这样我就可以获得所有效果后文档的最终高度,并使用新值设置文档高度。

Here's what I meant:这就是我的意思:

var timerHandler;
timerHandler = setTimeout(() => {
   document.documentElement.style.height = `${window.innerHeight}px`;
}, 350)

Hope it helps someone!希望它可以帮助某人!

In my case, I had a 1-2 pixel white line appearing at the bottom of the page and to the right of the page on Safari 16.0 on macOS Monterey.就我而言,我在 macOS Monterey 上的 Safari 16.0 上的页面底部和页面右侧出现了一条 1-2 像素的白线。 After trying all sorts of things, the problem was solved by closing and re-opening the tab.在尝试了各种方法之后,通过关闭并重新打开选项卡解决了问题。 I don't know how the tab acquired those extra pixels...我不知道标签是如何获得这些额外像素的……

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

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