最终效果如下图:
用到的背景图:
HTML结构:
<span class="button"><input type="button" name="" value="确定" /></span>
CSS:
.button{
background:url(bg.gif) no-repeat right -30px;
height:30px;
display:inline-block;
margin-left:10px;
}
.button input{
cursor:pointer;
position:relative;
left:-10px;
margin-right:-10px;
padding:0 10px;
border:0 none;
background:url(bg.gif) no-repeat 0 0;
height:30px;
line-height:22px;
color:#FFFFFF;
font-size:12px;
text-align:center;
}
在IE6、IE7下,当input的padding值为0时,随着按钮里value文字的增多,左右内边距也逐渐增大;当input设padding:0 10px;时,IE6,IE7左右内边距表现得比其它浏览器大,远远大于10px。
解决方法:input的样式加上overflow:visible;即可解决此问题,原因不明。