How to center <input> horizontally in a <div>?
This question already has an answer here:
应用以下到容器div
display: flex;
flex-flow: column wrap;
align-items: center;
div {
display: flex;
flex-flow: column wrap;
align-items: center;
}
<div style="width: 100vw; position: relative;">
<h1 style="text-align: center;">Title</h1>
<input type='text'>
</div>
Try this:
input[type="text"] {
display: block;
margin : 0 auto;
}
Example: Demo
Display block. input elements are inline.
<input type='text' style="display:block; margin : 0 auto;">
链接地址: http://www.djcxy.com/p/13220.html