测试中出现的问题,Safari5.1.7  input文本框有placeholder值时,css样式设置 line-heigh t与 heigh t等高,并不能使提示文本垂直居中,如下:

[css] view plain copy
  1. height40px;  
  2. line-height40px;  

解决方案一:使用padding使提示文字居中,如果font-size:14px,UI高度为40px,我们可以设height:14px,padding:13px 0;如下:

[css] view plain copy
  1. height16px;  
  2. padding12px 0;  

解决方案二:使用line-height:1px

[css] view plain copy
  1. height40px;  
  2. line-height1px;  


解决方案三:使用vertical-align: middle;

[css] view plain copy
  1. height40px;  
  2. vertical-alignmiddle;  


对于单行文本,使用line-height=height不垂直居中的问题只出现于input框上面,对于其他元素是垂直居中的,效果如下图:

input框的placeholder使用line-height在Safari上不垂直居中的问题


来源于:http://blog.csdn.net/u012076852/article/details/52062553

相关文章: