How to center <input> horizontally in a <div>?

This question already has an answer here:

  • How to horizontally center a <div> in another <div>? 82 answers
  • Place input box at the center of div 6 answers

  • 应用以下到容器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

    上一篇: 如何在div中插入两个内联按钮(css)?

    下一篇: 如何在<div>中水平居中<input>?