javascript - 在两个对象之间画一条垂直线

标签 javascript css reactjs typescript react-native

是否可以在 2 个文本对象之间画一条垂直线?我对此进行了调查,但这并不是我所需要的:

https://reactjsexample.com/draw-a-line-between-two-elements-in-react/

enter image description here

 <View style={styles.ridesFriends}>
          <Text style={styles.numbers}>132    </Text>
          <Text style={styles.numbers}>{numberOfFriends}</Text>
        </View>
  ridesFriends: {
    paddingTop: 70,
    alignItems: 'center',
    flexDirection: 'row',
    justifyContent: 'space-evenly',
    width: '100%',
  },
  numbers: {
    fontSize: 30,
    color: '#31C283',
    fontWeight: 'bold',
  },

编辑:

我尝试在两个数字之间添加一个 View :
  verticleLine:{
    height: '100%',
    width: 1,
    backgroundColor: '#909090',
  },
  <View style={styles.ridesFriends}>
          <Text style={styles.numbers}>132</Text>
          <View style={styles.verticleLine}></View>
          <Text style={styles.numbers}>{numberOfFriends}</Text>
        </View>

但它不在中心
enter image description here

最佳答案

一种方法是创建一个 View ,然后给它一个 height of 100% , width of 1pxbackground-colour .然后继续将此 View 放置在两个元素之间。

enter image description here

 <View style={styles.ridesFriends}>
    <Text style={styles.numbers}>132</Text>
    <View style={styles.verticleLine}></View>
    <Text style={styles.numbers}>2</Text>
 </View>

ridesFriends: {
    paddingTop: 70,
    alignItems: 'center',
    flexDirection: 'row',
    justifyContent: 'space-evenly',
    width: '100%',
    marginBottom: 20,
  },
  numbers: {
    fontSize: 30,
    color: '#31C283',
    fontWeight: 'bold',
  },
  verticleLine: {
    height: '100%',
    width: 1,
    backgroundColor: '#909090',
  }

关于javascript - 在两个对象之间画一条垂直线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62418215/

相关文章:

html - 为什么会这样? HTML 窗口宽度

javascript - 如何使用 useState() 钩子(Hook)在 ReactJS 中打开/关闭所有详细标签?

javascript - 在 JavaScript 中隐藏/欺骗引荐来源网址的最可靠方法是什么?

javascript - 如何在gulp中实现多源中流

twitter-bootstrap - 为什么 flex-fill 不在 Bootstrap 中创建相等的宽度?

javascript - 从事件获取文件时, typescript 对象可能为空

javascript - 通过文件提交 react 表单

javascript - 在 while 循环中定义变量

javascript - 如何让 Angular 识别绑定(bind)中的 HTML?

css - "float: center"在 CSS 中有效吗?