有人知道如何用React Native模拟display: inline-block吗?
基本上我想添加一个 display: inline-block 到创建的样式中。
示例:
我的目的是避免当前面的消息太长时将上面的“3 天前”分成两行。
谢谢!
[编辑] 这是我的 React Native 代码:
<View style={styles.contentContainer}>
<Text>
<Text style={styles.content}>{notification.content}</Text>
<Text style={styles.created}> {moment(notification.created, "YYYY-MM-DD[T]hh:mm:ss").subtract(n, 'hours').fromNow()}</Text>
</Text>
</View>
下面是相关的 CSS 对应:
contentContainer: {
flex: 1,
},
content: {
textAlign: 'left',
fontSize: 14,
},
created: {
textAlign: 'left',
fontSize: 10,
color: '#777777',
},
最佳答案
主要更改是将 flexWrap: 'nowrap'
添加到 created
样式。
关于css - 使用 React Native 模拟内联 block ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37619261/