【发布时间】:2017-09-06 03:43:08
【问题描述】:
我想编写样式表来显示如下图所示的布局:
头像:
我这样写代码:
<View style={styles.header}></View>
<View style={styles.meInfor}>
<Image style={styles.avatar}
source={require('../../images/cristiano-ronaldo.jpg')} />
</View>
和风格:
header:{
width: width,
height: 100,
backgroundColor: '#1270BA',
},
meInfor:{
width: width,
backgroundColor: '#FFFFFF',
alignItems: 'center',
justifyContent: 'center',
},
avatar: {
marginTop: -50,
width: 100,
height: 100,
borderRadius: 100,
}
我使用marginTop: - 50将头像拉到顶部,但结果如下:
不好的结果:
我怎样才能让这个头像的样式像第一张图片一样?
【问题讨论】:
-
尝试在头像中使用 position:'absolute'
-
我添加了这个属性并隐藏了头像。 :(
-
同时删除边距
-
仍然不适合我
-
等我试试看
标签: css react-native