【发布时间】:2020-01-19 16:24:10
【问题描述】:
请解释由什么原则视图尺寸与元素样式形成。我学习了 FlexBox,但它打破了我的所有理解。
代码
export const App = () => {
return (
<SafeAreaView>
<View style={styles.container}>
<View style={styles.element}>
<View style={styles.element1}></View>
</View>
</View>
</SafeAreaView>
);
};
const styles = StyleSheet.create({
container: {
width: '100%',
height: '100%',
backgroundColor: 'green',
},
element: {
// width: '100%',
// height: '100%',
backgroundColor: 'yellow',
// top: '5%',
},
element1: {
width: '50%',
height: '80%',
backgroundColor: 'red',
},
});
【问题讨论】:
-
为什么不在你的容器上使用
display: flex;? React 只是提供内容的一种方式。 CSS 仍然是 CSS。
标签: css react-native flexbox