WEB标准技术学习-隐藏input内的文字

隐藏input内的文字
时间: 2007-5-18 16:47:31 浏览:1446 

隐藏input的方法在浏览器中各不相同,我们用于网页使用它时并不希望它改变本身内联的属性,现单独分析如下:

首先写一个公用样式

程序代码

input{
 height:20px;
 width:50px;
}

1,IE6,IE7浏览器
 
程序代码

方法1
input{
 height:20px;
 width:50px;
 line-height:100em;
}
方法2
input{
 height:20px;
 width:50px;
 padding-top:60px;
}
方法3
input{
 height:20px;
 width:50px;
 line-height:8em;
}
方法4
input{
 height:20px;
 width:50px;
 font-size:80em;
}
方法5
input{
 height:20px;
 width:50px;
 line-height:25em;
}

2.FF浏览器

程序代码

方法1:
input{
 height:20px;
 width:50px;
 text-indent:-999px;
}

方法2:
input{
 height:20px;
 width:50px;
 font-size:0;
}


3.Opera浏览器
 
程序代码

方法1
input{
 height:20px;
 width:50px;
 padding-top:60px;
}


总结:从以上代码看,没有一个全适的样式适合所有浏览器,只能有针对性的加入HACK技术才可兼容各浏览器了!

关于Div之家 | 网站地图 | 版权隐私 | 联系站长:Divhome#126.com
Copyright © 2008 Divhome.com. All rights reserved. Design by Fred.ren 沪ICP备08016321号