html手机访问不变形,html – CSS3 100vh在移动浏览器中不变

我有一个非常奇怪的问题…在每个浏览器和手机版本我遇到这种行为:

>当您开始滚动页面时,当您加载页面(显示地址栏)时,所有浏览器都有顶部菜单。

> 100vh仅在视口的可见部分计算,所以当浏览器栏滑动100vh增加(以像素为单位)

>所有布局重新绘制并重新调整,因为尺寸已更改

>用户体验不好的跳跃效果

怎么可以避免这个问题?当我第一次听到viewport-height我很兴奋,我以为我可以使用它的固定高度块istead使用javascript,但现在我认为唯一的办法是事实上javascript与一些resize事件…

任何人可以帮助我/提出一个CSS解决方案?

简单测试代码:

/* maybe i can track the issue whe it occours... */

$(function(){

var resized = -1;

$(window).resize(function(){

$('#currenth').val( $('.vhBox').eq(1).height() );

if (++resized) $('#currenth').css('background:#00c');

})

.resize();

})

*{ margin:0; padding:0; }

/*

this is the Box which sould keep constant the height...

min-height to allow content to be taller than viewport if too much text

*/

.vhBox{

min-height:100vh;

position:relative;

}

.vhBox .t{

display:table;

position:relative;

width:100%;

height:100vh;

}

.vhBox .c{

height:100%;

display:table-cell;

vertical-align:middle;

text-align:center;

}

this div height should be 100% of viewport and keep this height when scrolling page

this div height should be 100% of viewport and keep this height when scrolling page

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值