以下、フレックスボックスの行があります。私が達成しようとしているのはこれです:私は5つのボックスの行を持っていたいと思いますし、flexBasis
(flex-basis
)を使っていくつかのボックス(すべてではない)の特定の幅を設定できるようにします。以下では、最初のボックスをflexBox: 'content'
またはflexBox: '150px'
(慎重に)サイズに設定しました。フレックスボックスでは、フレックスボックスにフレックスバースを設定し、残りのボックスに残りのスペースを設定します。
私はボックス2、3、4、5のサイズが同じで、その親の全部を占有する方法を探しています。
let {flexContainer, flexBox, custom} = StyleSheet.create({
flexContainer: {
backgroundColor: 'green',
padding: '30px',
flexDirection: 'row',
},
flexBox: {
padding: '30px',
flexBasis: '20%',
backgroundColor: 'red',
borderColor: 'blue',
borderWidth: 1
},
custom: {
flexBasis: 'content'
}
})
class SampleApp extends Component {
render() {
return (
<View style={flexContainer}>
<View style={[flexBox, custom]}>
meow
</View>
<View style={flexBox}>
meowmeow
</View>
<View style={flexBox}>
meowmeowmeow
</View>
<View style={flexBox}>
meow
</View>
<View style={flexBox}>
meow
</View>
</View>
)
}
}
// rendering
const rootTag = document.getElementById('react-root');
AppRegistry.registerComponent('SampleApp',() => SampleApp);
AppRegistry.runApplication('SampleApp', { rootTag });
http://codepen.io/reggi/pen/xqbZav?editors=0010