头部的header是绝对定位,每次动画调整,都有抖动一下或者是i闪烁一下
根本原因还是因为fixed在transform时失效了,所以要在动画进行过程中,用absolute覆盖掉fixed
<template>
<div id="app">
<!-- 头部导航区域 -->
<div class="home-header">
<p>首页</p>
</div>
<!-- 中间路由 router-view 区域 -->
<transition>
<router-view class="page"></router-view>
</transition>
<!-- 底部 Tabbar 区域 -->
<div class="tabbar-chil">
<Tabbar :page="1" style="position:absolute;"></Tabbar>
</div>
</div>
</template>
css 部分
<style>
#app {
width: 100%;
max-width: 640px;
min-width: 320px;
margin: auto;
overflow-x: hidden;
}
/* 头部区域 */
.home-header{
width: 100%;
max-width: 640px;
min-width: 320px;
margin: auto;
height: 1.4rem;
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 999;
background-color: white;
border-bottom: 1px solid #EAEAEA;
}
/* 中间部分动画 */
.v-enter{
/*进入动画*/
opacity: 0;
transform: translateX(100%);
}
.v-leave-to{
/*离开动画*/
opacity: 0;
transform: translateX(-100%);
position: absolute;
}
.v-enter-active,
.v-leave-active{
transition: all 0.5s ease;
}
/* fixed在transform时失效,可在动画进行过程中,用absolute覆盖掉fixed */
.page {
position: absolute;
top: 0;
bottom: 0;
width: 100%;
margin: 0 auto;
overflow-y: auto;
overflow-x: hidden;
-webkit-overflow-scrolling: touch;
}
/* tabbar区域 */
.tabbar-chil{
width: 100%;
max-width: 640px;
min-width: 320px;
margin: auto;
height: 1.5rem;
position: fixed;
bottom: 0;
left: 0;
right: 0;
z-index: 999;
-webkit-transform: translateZ(0);
background-color: white;
border-top: 1px solid #EAEAEA;
}
</style>
fixed在transform时失效,可在动画进行过程中,用absolute覆盖掉fixed
给消失的元素加个 position: absolute;
主要是在上面这两句话
在你的动画节点上加入
.page {
position: absolute;
top: 0;
bottom: 0;
width: 100%;
margin: 0 auto;
overflow-y: auto;
overflow-x: hidden;
-webkit-overflow-scrolling: touch;
}
就好了
网友评论