button 字体垂直居中的方法

  要让<input type="button" />中的文字垂直居中,可有两种办法:

  1:CSS设定样式

  <style type="text/css">

    input.btn_normal{border:1px; background:lightblue; font-size:12px; color:red; padding-bottom:0px; padding-top:3px; cursor:pointer}

  </style>

  <input type="button" class="btn_normal" value="确定" />

  利用CSS的padding来使文字垂直居中,首先padding-bottom设置位0,而padding-top则根据实际情况进行设置,肯定会有一个恰当的值会使得文字恰好

垂直居中。

  2:插入背景图片

  相比于上面的方法,本方法更为常用:先设计好背景图片,包含按钮中要显示的文字,然后将其设置为按钮的背景图片即可。

  <input type="button" value="确定" style="background:url('/img/1.gif')" />

  

原文地址:https://www.cnblogs.com/pricks/p/1621048.html