我们可以更改< input type =" file">样式? [英] Can we change <input type="file"> style?

查看:169
本文介绍了我们可以更改< input type =" file">样式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图更改HTML表单,输入类型文件。这是我的代码:

I tried to change the HTML form, input type file. Here is my code:

HTML,form id = form

HTML, form id = form

<input class="upload_file" type="file" id="file" name="file" />

.CSS

I tried both:
.upload_button{
  background: url('../images/upload_btn_bg.png') no-repeat;
  width: 200px; 
  height: 40px;
}

#form input[type=file]{
  background: url('../images/upload_btn_bg.png') no-repeat;
  width: 200px; 
  height: 40px;
}

这两种方法都不工作。我从一些网站,如Facebook,YouTube,谷歌或Twitter,看到,他们有不同的风格。

None of both of those methods works. I did see from some website, like facebook, youtube, google or twitter, they have different style. Wonder how they do it.

推荐答案

您不能对输入类型文件(除了巨大的黑客)做任何事情。我知道这听起来很可怕,但是网络标准还没有提出解决方案。

You can't do anything with input type file (other than huge hacks). I know this sounds horrible, but the web standards still haven't come up with a solution for that.

我建议的是,你使用更灵活,例如 swfUpload ,可让您更改档案,并在上传前检查档案大小。

What I would suggest though, is that you used something more flexible, such as swfUpload, which let's you change stiles, and also check for file size prior to uploading.

有些简单的例子可以在这里找到这里

Some neat examples of it can be found here

希望这有助于您

这篇关于我们可以更改&lt; input type =&quot; file&quot;&gt;样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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