template>
<div class="box">
<!-- 移动端三段式布局前置条件为在 app.vue或者index.html中给html和body,#app都加上height:100% -->
<header></header> <!-- 头部盒子 -->
<main></main><!-- 内容盒子 -->
<footer></footer><!-- 底部盒子 -->
</div>
</template>
<script>
export default {
}
</script>
<style lang="scss" scoped>
.box{
// box盒子为主盒子height必须为100% 开始弹性盒属性 flex-direction: column为纵向布局
// 头部和底部盒子为固定高度 给main盒子flex:1 让其沾满全屏 并附上属性overflow 这样就算内容过多他会自动开启滚动条不会影响
// 头部盒子和底部盒子位置
height: 100%;
width: 100%;
display: flex;
flex-direction: column;
header{
height: 100px;
background: green;
}
main{
flex: 1;
overflow: auto;
background: indigo;
}
footer{
height: 100px;
background: greenyellow;
}
}
</style>
最简单的移动端三段式布局
最新推荐文章于 2022-11-10 22:43:58 发布