读书人

自定义input type=”file”的样式以及

发布时间: 2012-10-19 16:53:35 作者: rapoo

自定义input type=”file”的样式以及引出的相关技术问题

?

http://www.itfeed.cn/post.asp?id=3420

?

因为不同浏览器下如果使用默认的input type=”file”元素,效果如下

自定义input type=”file”的样式以及引出的相关技术有关问题

为了保证不同浏览器下的UI一致我们有需求要自定义input type=”file”元素的样式

如何Style input type=”file”元素的相关长篇讨论
1. Styling an input type=”file”
http://www.quirksmode.org/dom/inputfile.html

2. Howto Style the Button of a input type=”file” Control
http://imar.spaanjaars.com/154/howto-style-the-button-of-a-input-typefile-control

翻译成白话文就是
1. 隐藏input type=”file”
2. 用CSS将a+span做成按钮样式,对其做事件绑定,点击之后触发input type=”file”的点击事件
3. 用input type=”text”显示input type=”file”选中文件的值

查看能工作的live code
http://jsfiddle.net/jihao/sFCQV/

HTML

读书人网 >Web前端

热点推荐