zoukankan      html  css  js  c++  java
  • 微信小程序实现头部、底部固定,中间滚动的布局

    如图:

     1、wxml

    <view class='wraper'>
      <view class='header'>header</view>
      <view class='main'>
        <scroll-view class='main-scroll' scroll-y style="height: 100%">
          <view class='main-list'>
            <view class='card' wx:for="{{cardList}}">
              <view class='card-box'></view>
              <view>{{item.name}}</view>
              <view class='card-content'>{{item.content}}</view>
            </view>
          </view>
        </scroll-view>
      </view>
      <view class='footer'>footer</view>
    </view>

    2、wxss

    page{
       100%;
      height:100%;
    }
    .wraper{
      display: flex;
      flex-direction: column;
       100%;
      height:100%;
    }
    .header{
      background: rgb(8, 117, 94);
      color: #fff;
      line-height: 100rpx;
      flex: 0 0 100rpx; /* 不放大不缩小固定100rpx */
    }
    .main{
      flex: 1;
      position: relative;
    }
    .main-scroll{
      position: absolute;
      left: 0;
      right: 0;
      top: 0;
      bottom: 0;
    }
    .main-list{
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
      margin-left: 2vw;
      margin-right: 2vw;
    }
    .card{
       47vw;
      margin-top: 10rpx;
      margin-bottom: 10rpx;
    }
    .card-box{
       100%;
      height: 200rpx;
      border-radius: 6rpx;
      background: #ccc;
    }
    .card-content{
      color: blue;
    }
    .footer{
      background: rgb(8, 117, 94);
      color: #fff;
      line-height: 100rpx;
      flex: 0 0 100rpx; /* 不放大不缩小固定100rpx */
    }

    3、js

    Page({
     
      /**
       * 页面的初始数据
       */
      data: {
        cardList: [
          {
            name: 'aa',
            content: 'bb'
          }, {
            name: 'aa',
            content: 'bb'
          }, {
            name: 'aa',
            content: 'bb'
          }, {
            name: 'aa',
            content: 'bb'
          }, {
            name: 'aa',
            content: 'bb'
          }, {
            name: 'aa',
            content: 'bb'
          }, {
            name: 'aa',
            content: 'bb'
          }, {
            name: 'aa',
            content: 'bb'
          },
        ]
      },
    })
  • 相关阅读:
    重定向是否可以重定向到post接口
    ForkJoin(工作窃取)初步使用,计算偶数集合
    Dubbo服务的三种发布模式
    mysql开启慢查询日志
    Hashmap的结构,1.7和1.8有哪些区别
    idea回滚已经push的代码
    rabbitmq集群安装配置
    restful好处,表单提交put/delete
    BIO/NIO/AIO待完成
    判断一个对象是否可以被回收
  • 原文地址:https://www.cnblogs.com/xubao/p/12434250.html
Copyright © 2011-2022 走看看