2017-08-16 75 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