2017-08-16 78 views
0

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, 
    }, 
}); 

然而,將它置於頂部角落。我可以將它移動到右側角落的唯一方法是用left: 500替換right: 5。但是那一種不是要走的路...

+0

有關使用'alignSelf什麼:「柔性端'' –

+0

也刪除CSS和樣式表標記,因爲它不會幫助,或者你會得到這個 –

+0

@JigarShah刪除的CSS解決方案。這有幫助。它將它移到右邊。但是,現在在中間水平地說出它的位置。 – Stophface

回答

1

請檢查子組件以下樣式:

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

嘗試設置position: relativefloat: right

+0

nope。這在反應原生境中不起作用 – Stophface