【发布时间】:2020-01-06 16:27:54
【问题描述】:
我的 React Native 应用程序中有以下代码:
<View
style={{
width: 50,
height: 50,
borderWidth: 1,
}}
>
<View style={{
width: 5,
height: 5,
backgroundColor: 'red',
top: 10,
left: 10
}}></View>
</View>
正如预期的那样,这会导致:
但是,如果我将 top 换成 bottom,我会得到:
如果我将子元素更改为position: absolute,它会按预期工作:
我想知道的:
1) 为什么第二张图片中的红点会出现在黑色方块的上方?
2) 既然红点是黑色方块的唯一孩子,为什么添加position: absolute会改变什么?
3) 为什么top 在所有三个图像中的行为都符合预期,而bottom 只有在第三个图像中的行为符合预期?
【问题讨论】:
标签: html css reactjs react-native css-position