如何使这个输入框居中
how to Centre This Input Box
我正在制作一个应用程序。在这里我有一个输入框和一个按钮。我想把它居中。我尝试使用 center
标签,但没有用。我尝试使用 align-items:center
仍然没有用。这该怎么做 ???这是我的程序 -
.form-inline {
display: flex;
flex-flow: row wrap;
align-items: center;
}
.form-inline label {
margin: 5px 10px 5px 0;
}
.form-inline input {
vertical-align: middle;
padding: 10px;
background: transparent;
border: 1px solid #ddd;
}
.form-inline button {
padding: 10px 20px;
background: transparent;
border-right: 1px solid #ddd;
border-top: 1px solid #ddd;
border-bottom: 1px solid #ddd;
color: white;
cursor: pointer;
}
<form class="form-inline" action="/">
<input id="email" placeholder="Enter email" name="email" />
<button type="submit">Submit</button>
</form>
如何实现???请帮忙
.formContainer {
display: block;
text-align: center;
}
.form-inline {
display: inline-flex;
align-items: center;
}
.form-inline label {
margin: 5px 10px 5px 0;
}
.form-inline input {
vertical-align: middle;
padding: 10px;
background: transparent;
border: 1px solid #ddd;
}
.form-inline button {
padding: 10px 20px;
background: transparent;
border-right: 1px solid #ddd;
border-top: 1px solid #ddd;
border-bottom: 1px solid #ddd;
color: white;
cursor: pointer;
}
<div class="formContainer">
<form class="form-inline" action="/">
<input id="email" placeholder="Enter email" name="email" />
<button type="submit">Submit</button>
</form>
</div>
**justify-content: center;**
.form-inline {
display: flex;
flex-flow: row wrap;
align-items: center;
justify-content: center;
}
form {
display: flex;
justify-content: center;
align-items: center;
/* Use this line if you have to add multiple elements */
flex-direction: column;
}
<form class="form-inline" action="/">
<div class="input-field">
<input id="email" placeholder="Enter email" name="email" />
<button type="submit">Submit</button>
</div>
</form>
使用 justify-content: center;
使其居中对齐
.form-inline {
display: flex;
justify-content: center;
align-items: center;
}
.form-inline label {
margin: 5px 10px 5px 0;
}
.form-inline input {
vertical-align: middle;
padding: 10px;
background: transparent;
border: 1px solid #ddd;
}
.form-inline button {
padding: 10px 20px;
background: transparent;
border-right: 1px solid #ddd;
border-top: 1px solid #ddd;
border-bottom: 1px solid #ddd;
color: black;
cursor: pointer;
}
<form class="form-inline" action="/">
<input id="email" placeholder="Enter email" name="email" />
<button type="submit">Submit</button>
</form>
我正在制作一个应用程序。在这里我有一个输入框和一个按钮。我想把它居中。我尝试使用 center
标签,但没有用。我尝试使用 align-items:center
仍然没有用。这该怎么做 ???这是我的程序 -
.form-inline {
display: flex;
flex-flow: row wrap;
align-items: center;
}
.form-inline label {
margin: 5px 10px 5px 0;
}
.form-inline input {
vertical-align: middle;
padding: 10px;
background: transparent;
border: 1px solid #ddd;
}
.form-inline button {
padding: 10px 20px;
background: transparent;
border-right: 1px solid #ddd;
border-top: 1px solid #ddd;
border-bottom: 1px solid #ddd;
color: white;
cursor: pointer;
}
<form class="form-inline" action="/">
<input id="email" placeholder="Enter email" name="email" />
<button type="submit">Submit</button>
</form>
如何实现???请帮忙
.formContainer {
display: block;
text-align: center;
}
.form-inline {
display: inline-flex;
align-items: center;
}
.form-inline label {
margin: 5px 10px 5px 0;
}
.form-inline input {
vertical-align: middle;
padding: 10px;
background: transparent;
border: 1px solid #ddd;
}
.form-inline button {
padding: 10px 20px;
background: transparent;
border-right: 1px solid #ddd;
border-top: 1px solid #ddd;
border-bottom: 1px solid #ddd;
color: white;
cursor: pointer;
}
<div class="formContainer">
<form class="form-inline" action="/">
<input id="email" placeholder="Enter email" name="email" />
<button type="submit">Submit</button>
</form>
</div>
**justify-content: center;**
.form-inline {
display: flex;
flex-flow: row wrap;
align-items: center;
justify-content: center;
}
form {
display: flex;
justify-content: center;
align-items: center;
/* Use this line if you have to add multiple elements */
flex-direction: column;
}
<form class="form-inline" action="/">
<div class="input-field">
<input id="email" placeholder="Enter email" name="email" />
<button type="submit">Submit</button>
</div>
</form>
使用 justify-content: center;
使其居中对齐
.form-inline {
display: flex;
justify-content: center;
align-items: center;
}
.form-inline label {
margin: 5px 10px 5px 0;
}
.form-inline input {
vertical-align: middle;
padding: 10px;
background: transparent;
border: 1px solid #ddd;
}
.form-inline button {
padding: 10px 20px;
background: transparent;
border-right: 1px solid #ddd;
border-top: 1px solid #ddd;
border-bottom: 1px solid #ddd;
color: black;
cursor: pointer;
}
<form class="form-inline" action="/">
<input id="email" placeholder="Enter email" name="email" />
<button type="submit">Submit</button>
</form>