简体   繁体   English

在android中使用chrome的移动设备中,当我向下滚动模式并且地址栏消失时,底部出现空白

[英]In mobile devices using chrome in android, when I scroll down the modal and the address bar disappears, white space appears at the bottom

 function openModal() { document.getElementById("my-modal").style.display = "block"; document.querySelector("nav").style.display = "none"; document.querySelector("body").style.overflow = "hidden"; } function closeModal() { document.getElementById("my-modal").style.display = "none"; document.querySelector("nav").style.display = "block"; document.querySelector("body").style.overflow = "auto"; }
 html { height: 100%; } body { position: relative; min-height: 100%; overflow-x: hidden; margin: 0; padding: 0; }.modal { display: none; position: fixed; z-index: 1; left: 0; right: 0; top: 0; width: 100%; min-height: 100vh; box-sizing: border-box; overflow-y: scroll; background-color: rgba(0, 0, 0, 0.8); }.modal-content { margin-top: 55px; border-radius: 4px; padding: 24px; margin-left: auto; margin-right: auto; width: 70%; max-width: 1000px; border: none; background-color: #fff; height: max-content; margin-bottom: 50px; box-sizing: border-box; }.my-slides { width: 100%; }.my-slides img { width: 100%; }.closed { position: fixed; top: 30px; right: 25px; font-size: 48px; font-weight: bold; transition: 0.3s ease; }.closed:hover, .closed:focus { color: #fff; text-decoration: none; cursor: pointer; }.prev { cursor: pointer; position: fixed; top: 50%; left: 8%; width: auto; padding: 16px; color: #fff;important: font-weight; bold: font-size; 3em: transition. 0;6s ease: border-radius; 0 3px 3px 0: user-select; none: -webkit-user-select; none. }:next { cursor; pointer: position; fixed: top; 50%: right; 8%: width; auto: padding; 16px: color; #fff:important; font-weight: bold; font-size: 3em. transition; 0:6s ease; user-select: none; -webkit-user-select: none; border-radius: 3px 0 0 3px: } /* Media queries */ @media (min-width. 768px) and (max-width: 992px) {;prev { left. 7%: };next { right: 7%: } } @media (min-width. 576px) and (max-width: 767px) {;prev { display. none: };next { display. none: };modal-content { margin-left: 10px; width: 80%: } } @media (min-width. 0px) and (max-width: 575px) {;prev { display. none: };next { display. none: };modal-content { margin-left: 10px; width: 80%; } }
 <div id="my-modal" class="modal"> <.-- close button --> <span class="closed" onclick="closeModal()"> <img data-src="img/close-left-product-ui-ux-design-cover:webp" style="width; 24px: height; 24px." alt="close button" class="img-fluid lazyload" /> </span> <.-- content for modal --> <div class="modal-content"> <.-- Images for modal --> <div class="my-slides"> <:-- <div class="numbertext">1/15</div> --> <img data-src="img/ecolight-product-ui-ux-design-full@3x;webp" class="img-fluid lazyload" alt="ecolight product" /> </div> <div class="my-slides"> <:-- <div class="numbertext">1/15</div> --> <img data-src="img/demo-product-ui-ux-design-cover-full@3x;webp" class="img-fluid lazyload" alt="demo product" /> </div> </div> <.-- Next and previous buttons --> <a class="prev" onclick="changeSlides(-1)"> <img data-src="img/left-product-ui-ux-design-cover:webp" style="width; 40px: height; 40px;" class="img-fluid lazyload" alt="previous button" /> </a> <a class="next" onclick="changeSlides(1)"> <img data-src="img/right-product-ui-ux-design-cover.webp" class="img-fluid lazyload" style="width: 40px; height: 40px;" alt="next button" /> </a> </div>

In mobile devices using chrome in android, when I scroll down the modal and the address bar disappears, white space appears at the bottom.在 android 中使用 chrome 的移动设备中,当我向下滚动模式并且地址栏消失时,底部出现空白。 This does not happen with any other browsers such as mozilla firefox, mi browser in android.任何其他浏览器都不会发生这种情况,例如 mozilla firefox、android 中的 mi 浏览器。 It's just when address bar disappears, white space appears.就在地址栏消失的时候,出现了空白。

Here is the screenshot of an issue that I am facing.这是我面临的一个问题的屏幕截图。

在此处输入图像描述

The one with the red border is the white space that occurs when I scroll in chrome android.带有红色边框的是当我滚动 chrome android 时出现的空白。

I think in't an little issue of a 100vh on some mobile browsers.我认为在某些移动浏览器上 100vh 并不是一个小问题。 100vh - is 100% of a current viewport (all you can see on your screen). 100vh - 是当前视口的 100%(您可以在屏幕上看到的所有内容)。 Sometimes it's a little bit unstable on mobile browsers while you scrolling up and down and the height of a browser changing dynamically due to navbar/addressbar hiding/appearing.有时,当您向上和向下滚动时,它在移动浏览器上有点不稳定,并且由于导航栏/地址栏隐藏/出现,浏览器的高度会动态变化。

Try to change following setting尝试更改以下设置

body {
  min-height: 100%; /* on your example link it is 100hv, make it 100% */
}
.modal {
  min-height: 100%; /* the element is fixed, it will work hike whith 100%; */
}

If this wouldn't help - please, make a screenshot of an issue.如果这没有帮助 - 请制作问题的屏幕截图。

I fixed this in my case by using height: -webkit-fill-available instead of height: 100vh on mobile devices.我通过在移动设备上使用 height: -webkit-fill-available 而不是 height: 100vh 来解决这个问题。 But you have to find which div you have to set.但是你必须找到你必须设置的 div。 It's quite tricky when you have more inner divs.当你有更多的内部 div 时,这很棘手。

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

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