flex

var LessonFlex = react.createClass({
  render: function() {
    return (
      <View style={styles.container}>
        <View style={styles.child1}>
          
        </View style={styles.child2}>
        <View>
          
        </View>
      </View>
    );
  }
});




// var styles = StyleSheet.create({
//   container: {
//     margin: 30,
//     width: 300,
//     height: 500,
//     backgroundColor: "#3399FF",
//     // 默认主轴方向是column
//     // 设置为横向排列 
//     flexDirection: "row",
//     // 设置主轴方向
//     justifyContent: "center",
//     // 交叉轴
//     alignItems: "center",
//   },
//   child1: {
//     width: 100,
//     height: 100,
//     backgroundColor: "#3399CC",
//   },
//   child2: {
//     width: 100,
//     height: 100,
//     backgroundColor: "#339999",
//   }
// });




/*
  flex 
  可以给组件指定flex,并且flex的值是数字。flex:1,表示组件可以撑满父组件所有的剩余空间
  同时存在多个并列的子组件, flex:1,表示均分
  如果这些并列的子组件的flex的值不一样,则谁的值更大,谁占据剩余空间的比例就更大(即占据剩余空间的比等于并列组件间flex值的比)
  练习
 */
var styles = StyleSheet.create({
  container: {
    margin: 30,
    flex: 1,
    backgroundColor: "#3399FF",
  },
  child1: {
    flex: 1,
    backgroundColor: "#3399CC",
  },
  child2: {
    flex: 2,
    backgroundColor: "#339999",
  }
});
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值