margin-left: auto and margin-right: auto not working on input

后端 未结 7 978
闹比i
闹比i 2021-02-01 01:25

I have an input in a form that I am trying to align in the center. Usually margin-left:auto and margin-right: auto fail to respond when display:

7条回答
  •  梦如初夏
    2021-02-01 02:06

    I found the solution for you

    you should specify element width

    input {
      display: block;
      width: 60px;
      margin: 10px auto;
      padding: 3px;
    }
    

提交回复
热议问题