Xecure Xecure - 6 months ago 31
CSS Question

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

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: block
isn't added to the CSS. I have added
display: block
to my CSS but still it isn't display as I would like it to.

I've made a JSFiddle to keep easier to understand: http://jsfiddle.net/XnKDQ/97/

Answer

In order for margin: 0 auto; to work, in addition to display:block a width needs to be specified.

Comments