【问题标题】:React Native Style conent space-betweenReact Native Style 内容空间
【发布时间】:2021-08-03 09:03:11
【问题描述】:

关于如何设置我的可触摸不透明按钮的样式以使其看起来像右图中的任何建议?

到目前为止,这是我的代码,我的结果是左边的图像..

我知道我需要应用 justify-content: space-between 但不知何故我无法弄清楚如何..

import {StyleSheet, View} from 'react-native';
import {TouchableOpacity} from 'react-native-gesture-handler';
import {Text} from 'react-native-elements';

const _positionTable = () => {
  return (
    <View style={styles.tabsContainer}>
      <TouchableOpacity style={styles.tab}>
        <Text style={styles.text}>MERCADO DE CAPITALES</Text>
      </TouchableOpacity>
      <TouchableOpacity style={styles.tab}>
        <Text style={styles.text}>FONDOS DE INVERSIÓN</Text>
      </TouchableOpacity>
      <TouchableOpacity style={styles.tab}>
        <Text style={styles.text}>MERCADO DE DINERO</Text>
      </TouchableOpacity>
    </View>
  );
};

const styles = StyleSheet.create({
  tabsContainer: {
    flexDirection: 'row',
    marginHorizontal: 20,
    marginTop: 20,
    maxWidth: '100%',
    alignContent: 'center',
    borderWidth: 1,
  },
  tab: {
    maxWidth: '30%',
    justifyContent: 'space-between',
    backgroundColor: 'orange',
  },
  text: {
    fontSize: 14,
    color: 'white',
    textAlign: 'center',
  },
});

export default _positionTable;

【问题讨论】:

    标签: css reactjs react-native flexbox styles


    【解决方案1】:

    你可以使用flex:1或通过计算设置width,但我想flex会做得更好。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-16
      • 2015-06-12
      • 2021-10-27
      • 2017-02-19
      • 2019-06-21
      • 2021-07-18
      相关资源
      最近更新 更多