Vertically align text within input field of fixed-height without display: table or padding?

后端 未结 16 2386
Happy的楠姐
Happy的楠姐 2020-12-01 01:27

The line-height property usually takes care of vertical alignment, but not with inputs. Is there a way to automatically center text without playing around with padding?

16条回答
  •  悲哀的现实
    2020-12-01 01:51

    Late to the party, but the current answers won't work if you have box-sizing: border-box set (which a lot of people do for form elements these days).

    Just reset the box sizing for IE8 to box-sizing: content-box; then use one of the padding / height answer.

提交回复
热议问题