为输入类型设置样式=“文件”按钮 [英] Styling an input type="file" button

查看:173
本文介绍了为输入类型设置样式=“文件”按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

解决方案

如何设置 type =file

样式文件输入是非常困难的,因为大多数浏览器不会改变css或javascript的外观。



即使输入的大小也不会响应喜欢:

 < input type =filestyle =width:200px>相反,您需要使用size属性:







b

 < input type =filesize =60/> 

对于任何比这更复杂的样式(例如改变浏览按钮的外观),您需要看看在本地文件输入顶部叠加一个样式按钮和输入框的棘手方法。 rm在 www.quirksmode.org/dom/inputfile.html 中提到的文章是我见过的最好的。


How to style the input type="file" button.

解决方案

Styling file inputs is notoriously difficult, as most browsers will not change the appearance from either css or javascript.

Even the size of the input will not respond to the likes of:

<input type="file" style="width:200px">

Instead you will need to use the size attribute:

<input type="file" size="60" />

For any styling more sophisticated than that (e.g. changing the look of the browse button) you will need to look at the tricksy approach of overlaying a styled button and input box on top of the native file input. The article already mentioned by rm at www.quirksmode.org/dom/inputfile.html is the best one I've seen.

这篇关于为输入类型设置样式=“文件”按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆