javascript - 停止显示内联文本

标签 javascript css react-native flexbox

我的文本显示为内联,我不希望这样。

为什么这段代码会导致它内联显示?

<Card style={{

  marginBottom: 10,
  flex: 1,
  flexDirection: 'row',
  backgroundColor: 'green'
}}>
  <CardItem style={{


    flex: 1,
    flexDirection: 'row',
    backgroundColor: 'red',

    alignItems: 'center'
  }}>
    <Text style={{
      color: '#FFFFFF',
      marginBottom: 15,
      width: '100%',
      backgroundColor: 'green',
      flexDirection: 'row',
    }}>
      {this.selectedProduct.name}
    </Text>
    <Text style={{
      color: '#FFFFFF',
      marginBottom: 15,
      backgroundColor: 'blue',
      width: '100%'
    }}>
      {this.selectedProduct.description}
    </Text>
    <Text style={{
      backgroundColor: 'yellow',
      color: '#FFFFFF',
      marginBottom: 15,
      width: '100%'
    }}>
      price: {this.selectedProduct.price ? this.selectedProduct.price + ' of your local currency' : 'not entered'}
    </Text>
  </CardItem>
</Card>

最佳答案

你的意思是“在一行中”?由于在其中使用了 flex - 它将所有子元素视为 flex 元素(也是纯文本)并相应地将它们分布在一行中。您可以将 flexDirection 更改为“column”以将文本放置在彼此之上

关于javascript - 停止显示内联文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45394871/

相关文章:

reactjs - react native : Passing props between components and componentWillMount() method

javascript - 图形在激活 negativeColor 的情况下奇怪地滑动

javascript - 使用每行上的删除按钮动态创建表单行并在每行上选择选项 - JQUERY

html - 一个元素上有多个 CSS 动画

html - CSS 不会实时更新,但适用于暂存

performance - WhatsApp 为何能如此快速地显示讨论内容?

javascript - Angular 显示 url 编码错误,如何获取解码版本?

javascript - 将动画函数作为参数传递

javascript - 无法读取未定义的属性 'scrollHeight'

javascript - 为什么在页面重新渲染之前调用 componentWillRecieveProps()?