css - 如何使用 react-native 和 align 让 flex 元素缩小到它们的内容?
问题描述
我有:
<StyledSurface style={{ flex: 1, flexDirection: 'row', flexWrap: 'wrap' }}>
{conversations.map((c, i) => (
<Surface style={{ backgroundColor: 'red', width: '46%', margin: '2%', flexDirection: 'column', flexShrink: 1, alignSelf: 'flex-start'}} key={i}>
<Text style={{flex: 1}}>{c.title}</Text>
</Surface>
))}
</StyledSurface>
这最终看起来像:
但是我希望每个红色框都缩小(垂直)以适应内容并具有相等的间距?
我错过了什么?
解决方案
在 View 容器上添加:
alignSelf: 'flex-start',
应该做的伎俩
推荐阅读
- microsoft-teams - Microsoft Graph API 报告中的统计数据不同于在线团队使用情况报告
- powershell - 尝试使用 aspnet_regiis 远程运行 Powershell。错误:对象已存在
- reactjs - 反应中不存在所需的请求部分
- python - 将 cprofile 与输入文件一起使用
- python - python将列表值发送到postgres
- javascript - 带有等待函数的无限while循环只执行一次
- postgresql - Postgres 连接模式
- privacy - 改组作为公共数据的匿名化技术
- excel - 数据输入后更新 Internet Explorer 窗口
- mysql - sql 'str_to_date' 函数错误截断了不正确的日期值并且不显示正确的时间格式