javascript - 在 StyledSheets 中将水平线移动到中心
问题描述
我画了一条这样的水平线。但是,它出现在屏幕的左侧。我不想增加宽度。我怎么能把它移到中心?我尝试将它与另一个视图以及 alignContent: 'center' 等一起包装,但它对我不起作用。
<View style={styles.horizontalLine}></View>
horizontalLine: {
marginTop: 25,
width: '80%',
height: 1,
//alignContent: 'center',
//width: 1,
backgroundColor: '#E0E0E0',
},
解决方案
添加一个 alignSelf:'center' 如下所示
horizontalLine: {
marginTop: 25,
width: '80%',
height: 1,
//alignContent: 'center',
//width: 1,
alignSelf: 'center',
backgroundColor: '#E0E0E0',
}
推荐阅读
- javascript - 打字稿吊装
- c++ - 模板参数中的括号,例如 std::function
- java - Fortify -Denial of Service_Format 字符串
- python - 关于python制作计算器报错的问题
- node.js - 在 node.js 应用程序中呈现页面之前解码 JWT cookie 和密码时出错
- python - 为什么我的 tkinter 盒子永远不会关闭,也不会在我的终端上打印
- extract - 来自 chess.com 的实时统计 chess960?
- java - 如何使用 Java 中的 GMail API 从电子邮件正文中获取 HTML(表格)
- android - 类型'Color'不是Flutter中'MaterialColor'类型错误的子类型?
- ruby - Ruby 内部和外部编码