第二天weex——flex布局

flex布局

前言

之间陆陆续续的写过前端页面,对于布局方式几乎是不懂的。后来接触了flex布局就打算认真学习一番,对于flex布局是一种灵活布局,弹性盒子

flex

关于flex它有两条轴线,flex-direction定义的是主轴线与之相关的是justify-content来定义布局格式(column或者row)。同时align-items是用来定义另一条次轴线(column或者row)的布局格式。个人感觉这就是flex学习中自己的难点。

weex中的flex

查阅官方文档看weex对于flex的支持。同时要注意一下css的支持,不然浏览器看好好的,手机一看就gg了。

小demo

在这里插入图片描述

相关的组件的使用参考官网的例子,这方面官网还是比较详细的

<template>
<div class="box">
<scroller scroll-direction="horizontal" show-scroller="false" >
    <text class="text" v-for="item in type" :key="item">{{item}}</text>
</scroller>
 <waterfall column-count="2" column-width="auto">
   <refresh :display="refreshing?'show':'hide'" @refresh="onrefresh" @pullingdown="onpullingdown">
     refresh....
   </refresh>
    <cell class="cell" v-for="num in lists" :key="num" >
      <text>{{num}}</text>
    </cell>
  </waterfall>
</div>

</template>
<script>
export default {
  data () {
    return {
      type: [
        '视频一区', '视频二区', '视频三区', '视频四区', '视频五区', '视频六区', '视频七区', '视频八区'
      ],
      lists: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I'],
      refreshing: false
    }
  },
  methods: {
    onrefresh () {
      this.refreshing = true
      setTimeout(() => {
        this.refreshing = false
      }, 2000)
    },
    onpullingdown () {

    }
  }
}
</script>
<style scoped>
.box{
    background-color: rgb(221, 221, 221);
    width: 750px ;
}
.scroller{
    flex-direction: row ;
    justify-content: center ;
    align-items: center ;
    height: 50px ;
}
.text{
    height:50px ;
    border-radius: 20px ;
    background-color: white;
    font-size: 30px ;
    padding-top:10px ;
    padding-bottom:10px;
    margin-left: 10px;
    margin-top: 5px
}
.cell{
  height: 350px;
  width: 350px ;
  background-color: white;
  border-radius: 25px ;
  margin-left: 5px;
    margin-top: 5px
}
</style>

结束语

没事看看官方文档,自己在谢谢小demo你会不断的发现一些小错误同时也能得到改正。比如width:100%;哈哈哈

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值