絕對坐標absolute
- 相對于父節(jié)點的4個角落,通過left、right征讲、top、bottom來調(diào)整相對于父窗口的坐標
<View style={[styles.circle, {position: 'absolute', bottom: 0, right: 0}]} />
當left橡娄、right同時存在時,left會覆蓋right的屬性
同理top和bottom同時存在時笋婿,top會覆蓋bottom的坐標屬性絕對坐標是相對于父節(jié)點的酷宵,而不是相對于根節(jié)點的
<View style={{flex: 1, backgroundColor: 'gray'}}>
<View style={{height: 100, backgroundColor: 'green'}}>
<View style={[styles.circle, {position: 'absolute', bottom: 0, right: 0}]}/>
</View>
</View>
相對坐標relative
- relative坐標是默認坐標豌习,
position: 'relative'
默認是添加的
<View style={{ flex: 1, backgroundColor: 'gray' }}>
<View style={{ height: 100, backgroundColor: 'green'}}>
<View style={[styles.circle, {position: 'relative', left: 0, top: 0 }]} />
<View style={[styles.circle, {position: 'relative', left: 0, top: 0 }]} />
</View>
</View>