输入字段对齐

  • 本文关键字:对齐 字段 css
  • 更新时间 :
  • 英文 :


我有一个电子邮件输入字段,必须在页面的中心对齐。我试过使用对齐,但它不会对齐输入字段。我可以对齐输入字段中的文本,但不能对齐物理输入字段。

"input" element is inline-element.
<div>
<input type="email" style="text-align:center" value="text is center"/>
</div>
this align the text in the input field.
you should be put style to parent.
<div style="text-align:center">
<input type="email" value="input box is center"/>
</div>
of course - "input" element should inline type.
if you changed "input" element's display type
try to other way. 
<div>
<input type="email" style="display:block;margin:0 auto;" value="input box is center"/>
</div>
or 
<div style="display:flex;justify-content:center;">
<input type="email" style="display:block;" value="input box is center"/>
</div>

最新更新