位于地址栏下方的横幅会改变高度,而且并不在DOM中。
底部的Position: fixed
元素被隐藏了。
您可以通过以下步骤查看:
- 在
Safari - iOS智能手机
中打开https://www.ounass.ae/clothing/ - 向下滚动以查看此应用横幅
- 点击
筛选条件
按钮。
位于地址栏下方的横幅会改变高度,而且并不在DOM中。
底部的Position: fixed
元素被隐藏了。
您可以通过以下步骤查看:
Safari - iOS智能手机
中打开https://www.ounass.ae/clothing/筛选条件
按钮。你尝试过使用-webkit-fill-available
吗?
html {
height: -webkit-fill-available;
}
body {
display: flex;
flex-direction: column;
margin: 0;
min-height: 100vh;
/* mobile viewport bug fix */
min-height: -webkit-fill-available;
}
main {
flex: 1;
}
<header>HEADER GOES HERE</header>
<main>MAIN GOES HERE</main>
<footer>FOOTER GOES HERE</footer>
我也遇到了同样的问题,但这可能不是解决方法,只是一种解决办法。
const updatePositionOfCtaButton = () => {
if (
window.navigator.userAgent.toLowerCase().includes('safari') &&
window.navigator.userAgent.toLowerCase().includes('mobile') &&
document.documentElement.clientHeight > window.innerHeight &&
!document.hidden
) {
document.querySelector('.callToActionButton').style.bottom = '44px';
} else {
document.querySelector('.callToActionButton').removeAttribute('style');
}
}
window.addEventListener('scroll', updatePositionOfCtaButton);
document.addEventListener('visibilitychange', updatePositionOfCtaButton);
我们还可以给CTA按钮添加transition
以添加一些动画效果。
.callToActionButton {
transition: bottom 0.16s linear 0s;
}