使用https://github.com/meliorence/react-native-render-html -我试图在我的html中居中文本,然而,它总是左对齐的,我如何将我的文本居中?
<View style={common.bannerText}>
<View style={common.textCenter}>
<HTML html="<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam</p>" />
</View>
</View>样式:
bannerText: {
paddingHorizontal: 20,
backgroundColor: colors.GREEN,
fontFamily: fonts.REGULAR,
fontSize: fonts.FONT_SIZE_MEDIUM,
color: 'white',
textAlign: 'center',
paddingVertical: 10,
marginVertical: 20,
flex: 1,
},
textCenter: {
alignItems: 'center',
},

发布于 2021-04-12 22:30:31
根据文档,传递一个参数"contentWidth“来设置该HTML容器的宽度,并使用"containerStyle”根据您的需要设置该内容的样式。
https://stackoverflow.com/questions/67059933
复制相似问题