首页 > 其他 > 详细

项目中常用到的布局 flex

时间:2021-04-15 15:14:28      阅读:15      评论:0      收藏:0      [点我收藏+]


1. 没header,footer固定
html
<div class="page">
<div class="top">
<div>sdnjsdcnddfre测试v京东方v你</div>
</div>
<div class="footer">删除</div>
</div>

css:
.page {
width: 100%;
overflow-y: scroll;
display: flex;
flex-direction: column;
height: 100vh;
}
.top {
flex: 1;
/* // 关键, 超出部分滚动 */
overflow-y: scroll;
}

.footer {
width: 343px;
line-height: 44px;
background: #ff5446;
margin: 0 auto;
font-size: 17px;
color: #fff;
text-align: center;
flex: 0;
}

2. header footer固定 中间滑动
html
<div class="wrap">
<div class="header">header</div>
<div class="main">main</div>
<div class="footer">footer</div>
</div>

css

.wrap {
display: flex;
flex-direction: column;
width: 100%;
height: 100vh;
}

.header,
.footer {
height: 40px;
line-height: 40px;
background-color: #D8D8D8;
text-align: center;
}

.main {
flex: 1;
width: 100%;
overflow: scroll;
}

头部固定:
使用vant van-sticky

项目中常用到的布局 flex

原文:https://www.cnblogs.com/renxiao1218/p/14661425.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!