[React-Native]flex-box实践(一)

2016-08-19  本文已影响26人  美乃滋酱啊
container: {
        justifyContent: 'center',
        alignItems: 'center'
    },

然后,在被包裹的Text中书写文字

 <View style={styles.container}>
      <Text style={styles.textStyle}>
           login
       </Text>
</View>
flex-box_Demo

这种样式的实现:

  container: {
        flex: 1,
        backgroundColor: '#f4f4f4',
        flexDirection: 'column',
    },

    child: {
        height: 50,
        backgroundColor: 'white',
        // 这是一个重要的实现
        flexDirection: 'row',
        justifyContent: 'space-between',
        alignItems: 'center'
    },

关键点在于,你需要在child中设置该Child的flex方向,并设置

 justifyContent: 'space-between',
 alignItems: 'center'
flex-box_demo
上一篇 下一篇

猜你喜欢

热点阅读