file_field 浏览按钮自定义 [英] file_field Browse button customize

查看:47
本文介绍了file_field 浏览按钮自定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 ruby​​ on rails 中自定义文件字段浏览"按钮.cutomise 从某种意义上说,我想更改按钮的颜色和样式.这在 ROR 中可能吗?如果是这样,任何人都可以帮我....

How can i customize the file field "Browse" button in ruby on rails. cutomise in sense i want to change the button color and style. Is this possible in ROR? If so , can any one help me out ....

推荐答案

All Rails 的 file_field 帮助器可以更轻松地创建文件输入,而不必直接编写 HTML(即.).不幸的是,文件输入的样式不太好,而且按钮特别容易卡在浏览器定义它应该看起来的方式上.

All Rails' file_field helper does is make it easier to create a file input, rather than having to code HTML directly (ie. <input type="file" ...>). Unfortunately, the file input is not very styleable, and the button especially tends to be stuck to the way the browser defines it should look.

但是,有一些技巧/技巧可以通过使用 CSS 和 Javascript 来欺骗浏览器使浏览按钮看起来像您想要的样子.您可以在 quirksmode 上查看有关它的文章.但是,由于这使用了 CSS opacity 属性,因此输入在不支持它的浏览器中看起来不正确.此外,如本文所述,这种方法还存在一些其他问题.

However, there are some techniques/hacks for tricking the browser into making the browse button look how you want it, by making use of CSS and Javascript. You can take a look at an article about it on quirksmode. However, as this makes use of the CSS opacity property, the input will not look right in browsers that do not support it. As well, there are some other problems with this approach, as outlined in the article.

这篇关于file_field 浏览按钮自定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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