margin-left: auto and margin-right: auto not working on input
Solution 1:
In order for margin: 0 auto;
to work, in addition to display:block
a width
needs to be specified.
Solution 2:
In my case, it was float: left
that I forgot about. So, make sure you apply float: none
to your input field.
You already have display: block
and margin: 0 auto
, you just need to set width too.
Example that should work:
input{
width:50% !important;
margin:0 auto !important;
display:block !important;
float:none !important;
}
If that doesn't work try adding !important
to the values or make sure your style is not overwritten by something else.