Jnl*_*Jnl 3 javascript css typescript reactjs react-native
是否可以在 2 个文本对象之间绘制一条垂直线?我调查了这个,但这并不是我所需要的:
https://reactjsexample.com/draw-a-line-between-two-elements-in-react/
<View style={styles.ridesFriends}>
<Text style={styles.numbers}>132 </Text>
<Text style={styles.numbers}>{numberOfFriends}</Text>
</View>
Run Code Online (Sandbox Code Playgroud)
ridesFriends: {
paddingTop: 70,
alignItems: 'center',
flexDirection: 'row',
justifyContent: 'space-evenly',
width: '100%',
},
numbers: {
fontSize: 30,
color: '#31C283',
fontWeight: 'bold',
},
Run Code Online (Sandbox Code Playgroud)
编辑:
我尝试在两个数字之间添加一个视图:
verticleLine:{
height: '100%',
width: 1,
backgroundColor: '#909090',
},
Run Code Online (Sandbox Code Playgroud)
<View style={styles.ridesFriends}>
<Text style={styles.numbers}>132</Text>
<View style={styles.verticleLine}></View>
<Text style={styles.numbers}>{numberOfFriends}</Text>
</View>
Run Code Online (Sandbox Code Playgroud)
一种方法是创建一个视图,然后给它一个height of 100%,width of 1px和background-colour。然后继续将此视图放置在两个元素之间。
<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',
}
Run Code Online (Sandbox Code Playgroud)
您可以简单地给左边的对象 ( styles.numbers) a border-right: 1px solid gray;。您可以对一行中的所有项目执行此操作,并且可以设置一个条件来删除“最后一个子项”的边框。
| 归档时间: |
|
| 查看次数: |
6941 次 |
| 最近记录: |