javascript - 试图让我的删除按钮在我的 Challengebox 组件的同一行/右侧 - React
问题描述
嘿!我试图让我的删除按钮在我的 Challengebox 组件的同一行/右侧。有没有办法用 flex-wrap 做到这一点?
.totalbox{
display: flex;
flex-direction: row;
flex-wrap: nowrap;
}
<div className="challengeboxes">
{
this.state.challenges.map(challenge =>
(
<div className="totalbox" key={challenge._id}>
<Challengebox
key={challenge._id}
id={challenge._id}
title={challenge.title}
description={challenge.description}
/>
<button onClick={() => this.onDelete(challenge._id)}>
Delete
</button>
</div>
))
}
</div>
解决方案
也许你可以试试下面
<div className="challengeboxes">
{
this.state.challenges.map(challenge =>
(
<div className="totalbox" key={challenge._id}>
<div className="challenge-box-container">
<Challengebox
key={challenge._id}
id={challenge._id}
title={challenge.title}
description={challenge.description}
/>
</div>
<button onClick={() => this.onDelete(challenge._id)}>
Delete
</button>
</div>
))
}
</div>
.totalbox .challenge-box-container {
width: 80%;
}
由于我不知道Challengebox
组件中有什么,我无法评论是否有任何问题。所以我只是想把它包装在一个 div 中并为其提供宽度。希望这可以帮助。
推荐阅读
- python - ValueError:“color kwarg 每个数据集必须有一种颜色”
- mysql - MySQL 从每个类别中选择前 N 个最便宜的产品
- pdf - 过滤除 PDF 中的交互式表单字段之外的任何内容
- c++ - 转换为不相关的引用类型是否违反了严格的别名规则?
- wordpress - 如何通过 wordpress API 端点返回内容
- sql - SQL Server Switch 基于先前值的分组
- php - 通过单击电子邮件中发送的按钮组件来更新用户的 sql 字段的代码
- git - 在本地 GIT 上,当本地 master 领先或与 origin/master 相比位于单独的分支时,如何将 master 与 origin/master 合并?
- c - 连续使用glMatrixMode()?
- nginx - 如何使用入口 nginx 负载平衡套接字