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

后端 未结 16 2394
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:39

    In Opera 9.62, Mozilla 3.0.4, Safari 3.2 (for Windows) it helps, if you put some text or at least a whitespace within the same line as the input field.

     

    (imagine an   after the input-statement)

    IE 7 ignores every CSS hack I tried. I would recommend using padding for IE only. Should make it easier for you to position it correctly if it only has to work within one specific browser.

提交回复
热议问题