【问题标题】:Simulate inline-block with React Native使用 React Native 模拟 inline-block
【发布时间】:2016-06-03 16:23:27
【问题描述】:

有谁知道如何使用 React Native 模拟显示: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',
},

【问题讨论】:

  • 请出示您的一些相关代码,以便我们为您提供帮助
  • 我刚刚编辑了我的帖子,感谢您的帮助 :-)
  • 工作正常:rnplay.org/apps/RgpZ5w
  • 也许我不清楚或者我不明白你做了什么,所以我在上面澄清了我的问题......
  • 知道了,看看我的问题

标签: css react-native flexbox


【解决方案1】:

主要变化是将flexWrap: 'nowrap'添加到created样式。

工作示例:https://rnplay.org/apps/RgpZ5w

【讨论】:

  • 完美运行!谢谢!
猜你喜欢
  • 1970-01-01
  • 2013-01-27
  • 1970-01-01
  • 1970-01-01
  • 2013-05-18
  • 2021-07-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多