广场右上角反应本土
问题描述:
父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
。但是那一种不是要走的路...
答
请检查子组件以下样式:
const styles = StyleSheet.create({
container: {
...StyleSheet.absoluteFillObject,
alignSelf: 'flex-end',
marginTop: -5,
position: 'absolute', // add if dont work with above
}
});
有关使用'alignSelf什么:“柔性端'' –
也删除CSS和样式表标记,因为它不会帮助,或者你会得到这个 –
@JigarShah删除的CSS解决方案。这有帮助。它将它移到右边。但是,现在在中间水平地说出它的位置。 – Stophface