隐藏输入type =文件上的浏览按钮 [英] Hide the browse button on a input type=file
本文介绍了隐藏输入type =文件上的浏览按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法隐藏浏览按钮,只留下适用于所有浏览器的文本框?
Is there a way to hide the browse button and only leave the text box that works in all browsers?
我已尝试设置页边距,但在每个浏览器中显示不同。
I have tried setting the margins but they show up different in each browser
推荐答案
不,你可以做的是一个(丑陋的)解决方法,但主要使用
No, what you can do is a (ugly) workaround, but largely used
- 创建一个普通的输入和一个图像
- 使用不透明度0创建文件输入
- 当用户点击图片时,您将模拟对文件输入的点击
- 文件输入更改时,将其值传递到正常输入(以便用户可以看到路径)
- Create a normal input and a image
- Create file input with opacity 0
- When the user click on the image, you simulate a click on the file input
- When file input change, you pass it's value to the normal input (so user can see the path)
可以看到完整的说明以及代码:
Here you can see a full explanation, along with code:
http:/ / www.quirksmode.org/dom/inputfile.html
这篇关于隐藏输入type =文件上的浏览按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文