您的位置:首页 > Web前端 > CSS

file 元素样式的模拟(兼容模式)

2011-09-05 18:14 441 查看
<script>

function fclick(obj){

with(obj){

style.posTop=event.srcElement.offsetTop

var x=event.x-offsetWidth/2

if(x<event.srcElement.offsetLeft)x=event.srcElement.offsetLeft

if(x>event.srcElement.offsetLeft+event.srcElement.offsetWidth-offsetWidth)x=event.srcElement.offsetLeft+event.srcElement.offsetWidth-offsetWidth

style.posLeft=x

}

}

</script>


<style>

input{border:1px solid #333333;color:#666666;background:#eeeeee;font:normal 12px Tahoma;height:18px}

</style>

<form method="post" action="" enctype="multipart/form-data">

<input id="f_file">   <span style="position:relative">input type="button" onmouseover="fclick(t_file)" value="选择上传文件">

<input name="upload" type="file" style="position:absolute;filter:alpha(opacity=30);opacity:0;width:30px;" id="t_file" onchange="f_file.value=this.value" size="9" hidefocus>
</span>
<br><input type="submit" value="提交">

</form>


html中file格式的宽度在IE下面可以用width来定义,但在firefox下面却要用size来定义其宽度
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: