微信小程序flex布局怎么实现上中下3行铺满整个窗口。

问题描述:

在微信小程序中使用flex实现上中下3行布局铺满整个窗口。

如图

输入图片说明

**WXML **

<!--/*
***HotApp云笔记,基于HotApp小程序统计云后台
***免费云后台申请地址 https://weixin.hotapp.cn/cloud
***API 文档地址:https://weixin.hotapp.cn/api
***小程序技术讨论QQ群:173063969
*/-->
<!--index.wxml-->
<view class="container">
    <view class='title'><input name="title" placeholder-class="placeholder" placeholder="在此输入标题(可选)" value="{{item.value.title}}" /></view>
    <view class='row'>
        <textarea class='text' placeholder-class="placeholder"  name="content" focus="{{focus}}" value="{{item.value.content}}" placeholder="点击添加文本" />
    </view>
    <view class='bottom'>
        <button formType="submit" class='btn success'>保存</button>
    </view>
</view>

WXSS

/*
***HotApp云笔记,基于HotApp小程序统计云后台
***免费云后台申请地址 https://weixin.hotapp.cn/cloud
***API 文档地址:https://weixin.hotapp.cn/api
***小程序技术讨论QQ群:173063969
*/
page{
    width: 100%;
    height: 100%;
}
.container{
    flex-flow:column nowrap;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}
.title{
    margin: 15rpx 5%;
    width: 90%;
    text-align: center;
    height: 60rpx;
    font-size: 38rpx;
    border-bottom: 1px solid #f5f5f5;
}
.row{
    flex: 1;
    display: flex;
    width: 90%;
    height: auto;
    margin: 0 5%;
    overflow: hidden;
}
.row .text{
    flex: 1;
    width: 100%;
    height: auto;
    font-size: 36rpx;
    color: #666;
}

.bottom{
    width: 100%;
    background: #fff;
    display: flex;
    flex-flow:row nowrap;
    justify-content: center;
    align-items: center;
}
.bottom .btn{
    flex: 1;
    line-height: 2;
    padding-top: 10rpx;
    padding-bottom: 10rpx;
    margin: 30rpx 30rpx;
}
.btn.success{
    background: #1aad19;
    color: #fff;
}

在wxss里必须加

page{ width: 100%; height: 100%; }

否则container的height: 100%;不起作用从而导致container 的高不能填充满整个窗口。

效果如下:

输入图片说明

HotApp云笔记,基于HotApp小程序统计云后台

免费云后台申请地址 https://weixin.hotapp.cn/cloud

API 文档地址:https://weixin.hotapp.cn/api

小程序技术讨论QQ群:173063969

转载于:https://my.oschina.net/u/3073834/blog/795766

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值