admin管理员组文章数量:1417459
I have 3 input fields, the first one I want by itself, but the next two I need side by side. So far I tried to add a className row to the ones that need to be side by side, but they still show up below each other
{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>
)}
Is it possible to get them side by side without using an external library like bootstrap?
I have 3 input fields, the first one I want by itself, but the next two I need side by side. So far I tried to add a className row to the ones that need to be side by side, but they still show up below each other
{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>
)}
Is it possible to get them side by side without using an external library like bootstrap?
Share Improve this question edited Feb 1, 2021 at 22:53 asked Feb 1, 2021 at 18:06 user14985872user14985872 3- This sounds like a styling issue, not a React or JavaScript issue. What styling is being applied to these elements? What CSS rules have you written to change their styling? Looking at the resulting HTML along with the CSS being applied to it is likely to be more useful debugging than just looking at the JSX code. – David Commented Feb 1, 2021 at 18:09
- What about using a TABLE? That's what I normally do – ControlAltDel Commented Feb 1, 2021 at 18:10
- You should look into using material-ui or add bootstrap (only really need the css). Both frameworks have grid systems that make handling spacing and alignment very easy. – Nicholas_Jones Commented Feb 1, 2021 at 19:38
1 Answer
Reset to default 3You can use flex
from CSS like:
.side-by-side {
display: flex;
flex-direction: row;
}
<div>
<Input1 />
<div className="side-by-side">
<Input2 />
<Input3 />
</div>
</div>
本文标签: javascriptHow to place two input fields side by side in reactStack Overflow
版权声明:本文标题:javascript - How to place two input fields side by side in react - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745267462a2650690.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论