这个问题让我整个上午都快发疯了。我一直在尝试让我的输入字段具有自定义背景,以便在 IE 中正确对齐。我读到其他问题说 line-height 会解决它,但这并没有奏效。
它在 chorme/safari/etc 中看起来不错,但在 IE8 中文本卡在输入区域的顶部。 (Stack 还不允许我发布图片)。我的 CSS 是:
#email {
background: url('BACKGROUND IMAGE') left top no-repeat;
background-size: 273px 38px;
width: 273px;
height: 38px;
line-height: 38px;
border: 0;
margin: 0 0 5px;
font: bold 12px arial, helvetica, sans-serif;
color: #777;
padding:0 8px;
outline: none;
float:left;
}
和 HTML:
<input id="email" type="text" name="email" size="14" value="your email address" onfocus="if(this.value=='your email address') {this.style.color='#333'; this.value='';}" onblur="if(this.value== '') {this.style.color='#808080'; this.value='your email address';}" />
关于如何让我的输入文本在 IE 8 及更低版本中垂直居中的任何想法?
最佳答案
这应该很容易修复。 line-height 属性很重要,但当您使用速记字体属性时,它似乎在 IE8 中丢失了。尝试将行高添加到速记字体属性中,并删除您单独声明的行高。
#email {
background: url('BACKGROUND IMAGE') left top no-repeat;
background-size: 273px 38px;
width: 273px;
height: 38px;
border: 0;
margin: 0 0 5px;
font: bold 12px/38px arial, helvetica, sans-serif;
color: #777;
padding:0 8px;
outline: none;
float:left;
border:1px solid #999;
}
这是一个 jsFiddle example 为你(添加边框只是为了显示它是如何对齐的)。
关于css - IE 中的输入字段未垂直对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10094596/