javascript - Flexbox 生成器在我的 React 应用程序中显示不佳

标签 javascript css react-native flexbox react-native-web

我正在测试https://yogalayout.com/playground并创建了该模板:

import React, {Component} from 'react';
import {View} from 'react-native';

export default class MyLayout extends Component {
  render() {
    return (
      <View style={{
        flex: 1,
        width: 500,
        height: 500,
        justifyContent: 'space-between',
      backgroundColor: 'red',
      }}>
        <View style={{
          flex: 1,
          width: 100,
          height: 100,
          backgroundColor: 'blue',
        }} />
        <View style={{
          flex: 1,
          width: 100,
          height: 100,
          backgroundColor: 'green',
        }} />
        <View style={{
          flex: 1,
          width: 100,
          height: 100,
          backgroundColor: 'purple',
        }} />
      </View>
    );
  }
};

我希望得到这样的结果:

flexbox normal

相反,我有这个:

flexbox broken

什么可能会破坏我的 Flexbox 布局?

最佳答案

React Native 中默认的 flexDirectioncolumn。因此,尝试将其设置为容器 View 中的 row

<View style={{
        flex: 1,
        width: 500,
        height: 500,
        justifyContent: 'space-between',
        backgroundColor: 'red',
        flexDirection: "row"
      }}>
  .
  .
  .

关于javascript - Flexbox 生成器在我的 React 应用程序中显示不佳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60130603/

相关文章:

javascript - 重新排序 dom 中的 html 元素

css - css选择器引擎的具体实现

javascript - 将无序列表制作成下拉菜单

ios - 我们如何将我们在 dribbble 上看到的精彩动画实现到 ios 应用程序?

javascript - 在 Firefox 上使用 HTTPS 时强制 getUserMedia 重新提示

JavaScript 导入 JSON 数据 - 循环按长/纬度位置排序

javascript - 为什么谷歌不转义他们的分析跟踪代码?

javascript - 将 html 转换为 pdf

javascript - 如何在 React Native FlatList 中按下组件时更改其颜色

android - React Native - Android - 防止多次点击/点击