【问题标题】:In flexbox why my buttons seemed compressed?在 flexbox 中,为什么我的按钮似乎被压缩了?
【发布时间】:2020-02-01 06:53:27
【问题描述】:

为什么我创建的按钮在使用 flexbox 时似乎被压缩了?

有没有办法让它变成中等大小?

render () {
  const listItems = this.state.content.map((data) => {
    return (
      <View>
        <Card>
          <Text h5>{data.TITLE}</Text> 
          <Text h5>{data.CONTENT}</Text>

          <View style={styles.container}>
            <Button title="Edit" onPress={this.editAnnouncement} containerStyle={{marginLeft: 10, width: 120}} />
            <Button title="Delete" onPress={this.editAnnouncement} containerStyle={{marginRight: 10, width: 120}} />
          </View>
        </Card>
      </View>
    )
})

const styles = StyleSheet.create({
  container: {
    flex: 1,
    flexDirection: 'row',
    justifyContent: 'flex-end',
    padding: 15,
  },
});

【问题讨论】:

  • 考虑将flex-shrink 设置为0。

标签: css react-native flexbox stylesheet


【解决方案1】:

我使用了 flexBasis 并将其设置为 40

const styles = StyleSheet.create({
  container: {
    flex: 1,
    flexDirection: 'row',
    justifyContent: 'flex-end',
    flexBasis: 40,
    paddingTop: 10,
    paddingBottom: 10,
  },
});

【讨论】:

    猜你喜欢
    • 2013-02-27
    • 2022-01-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多