首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >文本左对齐而不是居中

文本左对齐而不是居中
EN

Stack Overflow用户
提问于 2021-04-12 22:07:49
回答 1查看 31关注 0票数 0

使用https://github.com/meliorence/react-native-render-html -我试图在我的html中居中文本,然而,它总是左对齐的,我如何将我的文本居中?

代码语言:javascript
复制
     <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>

样式:

代码语言:javascript
复制
  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',
  },

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-04-12 22:30:31

根据文档,传递一个参数"contentWidth“来设置该HTML容器的宽度,并使用"containerStyle”根据您的需要设置该内容的样式。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67059933

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档