admin管理员组文章数量:1431262
I have <button/>
and <input/>
inside a container. How can I get them to align in the same row and in the middle of the container vertically (<div className="container">
)?
This is what I have so far:
<div className="container">
<div>
<input className="form-control" placeholder='Enter Email'/>
</div>
<div>
<button type="submit" className="btn"> Register </button>
</div>
</div>
With className="container":
.container {
width: 80%;
margin: 0 auto;
padding: 0 137px;
}
EDIT
I tried what you suggested with the following but the <input/>
and <button/>
is still on top of each other:
The top black portion is a navigation bar and I want to align everything inside the bar horizontally, next to each other from left to right.
<div className="container">
<h1>
TESTING
</h1>
<input
className="form-control"
id="input-field"
placeholder='Enter Email'
/>
<button
type="submit"
className="btn"
>
Register
</button>
</div>
I have <button/>
and <input/>
inside a container. How can I get them to align in the same row and in the middle of the container vertically (<div className="container">
)?
This is what I have so far:
<div className="container">
<div>
<input className="form-control" placeholder='Enter Email'/>
</div>
<div>
<button type="submit" className="btn"> Register </button>
</div>
</div>
With className="container":
.container {
width: 80%;
margin: 0 auto;
padding: 0 137px;
}
EDIT
I tried what you suggested with the following but the <input/>
and <button/>
is still on top of each other:
The top black portion is a navigation bar and I want to align everything inside the bar horizontally, next to each other from left to right.
<div className="container">
<h1>
TESTING
</h1>
<input
className="form-control"
id="input-field"
placeholder='Enter Email'
/>
<button
type="submit"
className="btn"
>
Register
</button>
</div>
Share
Improve this question
edited Sep 10, 2016 at 6:23
asked Sep 8, 2016 at 0:08
user2423124user2423124
1
- 2 These are very basic html5/css questions. Nothing to do with reactjs really. I suggest you study up a bit on these topics – Marc Commented Sep 8, 2016 at 22:19
1 Answer
Reset to default 2You can use flex-box for this.
Swap out the class
attribute for className
in react
edit: To answer your edited question:
- align everything horizontally with
align-items: center
on the flex container - Ensure the
input
andbutton
don't break into separate lines by wrapping them together in a container element.
h1 { color: white; }
.container {
display: flex;
justify-content: center;
align-items: center;
background-color: #222;
}
.email-holder {
margin-left: 10px;
}
<div class="container">
<h1>TESTING</h1>
<div class="email-holder">
<input class="form-control" placeholder='Enter Email'/>
<button type="submit" class="btn"> Register </button>
<div/>
</div>
本文标签: javascriptHow to align ReactJS39s ltbuttongt and ltinputgt in same rowhorizontallyStack Overflow
版权声明:本文标题:javascript - How to align ReactJS's <button> and <input> in same rowhorizontally? - Stack Ov 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745457243a2659160.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论