file_field Browse button customize

后端 未结 1 470
悲&欢浪女
悲&欢浪女 2021-01-18 07:00

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 an

相关标签:
1条回答
  • 2021-01-18 07:34

    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.

    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.

    0 讨论(0)
提交回复
热议问题