【发布时间】:2021-01-07 16:35:31
【问题描述】:
我遇到了 Flex Box 问题我正在尝试获取这种类型的网格视图:
而且我尝试了很多位置都没有任何运气,我尝试的最后一个是:
return (
<>
<View style={styles.container}>
<View style={styles.column}>
<View style={styles.row}>
<View style={[styles.box, { backgroundColor: 'yellow' }]} />
</View>
</View>
<View style={styles.column}>
<View style={[styles.box, { backgroundColor: 'green' }]} />
<View style={[styles.box, { backgroundColor: 'lightblue' }]} />
</View>
<View style={styles.space_between_columns} />
<View style={styles.column}>
<View style={[styles.box, { backgroundColor: 'grey' }]} />
<View style={[styles.box, { backgroundColor: 'purple' }]} />
</View>
</View>
</>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
flexDirection:'row',
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
row: {
flexDirection:'row',
justifyContent:'space-between',
alignItems:'center',
height:200,
width:50
},
column: {
flexDirection:'column',
justifyContent:'space-between',
alignItems:'center',
height:200,
width:50
},
space_between_columns:{
width:100
},
box: {
height:50,
width:50
}
});
但不是给我想要的顶部部分,而是这样:
有什么想法吗?
亲切的问候
【问题讨论】:
-
它真的做到了,太棒了,我保证我会的!!!
标签: css react-native flexbox