Centering text (vertically) inside a textbox using CSS

后端 未结 3 643
被撕碎了的回忆
被撕碎了的回忆 2021-01-12 17:42

I\'m currently working with a textbox that has a background. I was wondering if it\'s possible to center text (vertically) inside the textbox.

important

3条回答
  •  有刺的猬
    2021-01-12 18:34

    I know this one's a bit old, but I've just run into the same problem. The solution given here didn't help me which seemed strange. In my case it was the line height that was set to "1em". Changing the line height to something that resembled the height of the text box, rather than the size of the font it contained was the solution. This also continues to function as expected in Firefox, etc.

提交回复
热议问题