【发布时间】:2021-11-03 06:45:54
【问题描述】:
我创建了一张包含一些文字和图标的卡片。 我想将该图标对齐到底部。这是我的代码:
export default function App() {
return (
<View
style={{
borderWidth: 1,
borderColor: 'red',
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
paddingVertical: 10,
paddingHorizontal: 15,
}}>
<View style={{ flex: 1 }}>
<View style={{ flexDirection: 'row' }}>
...
</View>
<View
style={{
marginLeft: 10,
height: '100%',
// justifyContent: 'flex-end',
// alignContent: 'flex-end',
}}>
<View
style={{
justifyContent: 'center',
alignItems: 'center',
alignSelf: 'center',
alignContent: 'center',
}}>
<MyIcon color="gray" />
</View>
</View>
</View>
);
}
function MyIcon({ color }) {
return (
<View
style={{
borderRadius: 15,
width: 30,
height: 30,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'lightblue',
}}>
<Svg ...>
...
</Svg>
</View>
);
}
工作零食是here。
包含图标的圆圈应该在底部,我不需要absolute,因为我认为。
我尝试flex-end,但似乎不起作用。
【问题讨论】:
-
尝试删除评论第 55 行
justifyContent: 'flex-end',它会起作用。
标签: css react-native vertical-alignment