[英]How to place two input fields side by side in react
我有 3 個輸入字段,第一個我自己想要,但接下來的兩個我需要並排。 到目前為止,我嘗試將 className 行添加到需要並排的行中,但它們仍然顯示在彼此下方
{pillTabs.selected === 4 && (
<div>
<div className="row"> //need the ones in this div side by side
<Input
label="Name"
type="text"
placeholder="Enter name"
inputId="basicInput"
value={name}
onChange={e => this.setState({ name: e.target.value })}
></Input>
<Input
label="Label"
type="text"
placeholder="Enter label"
inputId="basicInput"
value={name}
onChange={e => this.setState({ name: e.target.value })}
></Input>
</div>
</div>
)}
是否可以在不使用諸如引導程序之類的外部庫的情況下將它們並排放置?
您可以使用 CSS 中的flex
,例如:
.side-by-side {
display: flex;
flex-direction: row;
}
<div>
<Input1 />
<div className="side-by-side">
<Input2 />
<Input3 />
</div>
</div>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.