簡體   English   中英

將元素放置在反應本機的右上角

[英]Placing element in the top right corner in react native

component有如下樣式

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#FFF',
    alignItems: 'center',
    justifyContent: 'center',
  },
});

我在這個組件中放置了另一個component 我想要它在右上角。

自然地,我會在這個子component中使用以下樣式:

const styles = StyleSheet.create({
  container: {
    ...StyleSheet.absoluteFillObject,
    top: 20,
    right: 5,
  },
});

但是,它將它放在左上角 我可以將它移到右上角的唯一方法是將right: 5替換為left: 500 但這不是要走的路......

請檢查下面的子組件樣式表:

const styles = StyleSheet.create({
  container: {
    ...StyleSheet.absoluteFillObject,
    alignSelf: 'flex-end',
    marginTop: -5,
    position: 'absolute', // add if dont work with above
  }
});

嘗試設置position: relativefloat: right

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM