React Native absolute positioning horizontal centre

后端 未结 7 766
栀梦
栀梦 2021-01-30 06:23

It seems that with position:absolute in use an element cannot be centred using justifyContent or alignItems. There\'s a workaround to use

相关标签:
7条回答
  • 2021-01-30 06:56

    You can try the code

    <View
        style={{
          alignItems: 'center',
          justifyContent: 'center'
        }}
      >
        <View
          style={{
            position: 'absolute',
            margin: 'auto',
            width: 50,
            height: 50
          }}
        />
      </View>
    
    0 讨论(0)
提交回复
热议问题