input file 浏览器兼容问题

本文介绍了一种使用遮罩层来隐藏文件输入框的真实位置的方法,从而实现统一的样式设计。这种方法通过设置绝对定位和透明度,使文件选择按钮能够覆盖在input file元素之上,同时保持文件选择的功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

主要思想就是用一层遮罩input file 的位置,实现样式的统一。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
<form>
<input name="upload" type="file" style="width:200px;position:absolute;opacity:0;filter:alpha(opacity=0);"  onchange="this.form.inputs.value=this.value.substr(this.value.lastIndexOf('\\')+1);"/>
<input name="inputs" type="input" style="width:121px; height:14px;"  /> <input name="" type="button" value="浏览..." style="width:70px; height:20px; border:1px solid #003c74;"/>
</form>
</body>
</html>

转自:http://blog.youkuaiyun.com/sdaiweiy/article/details/7672570
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值