Forum: Ruby on Rails How change CSS style fo file_field_tag?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
0daa01e327de6c68ad4d6244759fec2f?d=identicon&s=25 Artemiy Baranov (artemiy)
on 2017-02-07 22:08
Hello, All.

How change CSS style for  <%= file_field_tag ...> to watching in text
style?

For example, <%= submit_tag ...> happened change style:

<div class="actions">
  <%= submit_tag "Upload", :class => "button" %>
</div>

.button{
  border: 0;
  background: white;
  color: darkgreen;
  width: 300px;
  height: 30px;
  position: absolute;
}

Maybe possibly do it for <%= file_field_tag ...> ?
Thank you.
7c42bc2b2720119ba03241fd0ea91515?d=identicon&s=25 Andres Coppola (peyu)
on 2017-02-28 18:07
You already has your answer:

<%= submit_tag "Upload", :class => "button" %>

There you have the class "button" , if you want to change the style, you
must change the css code...

Or maybe I didn't understand your question...
0daa01e327de6c68ad4d6244759fec2f?d=identicon&s=25 Artemiy Baranov (artemiy)
on 2017-03-02 19:49
Attachment: FileToUpload.png (6 KB)
Hello Andres. Thank you for answers!

On image it is seen, button "Upload" changed CSS style, but button
"Choose File"  remained unchanged.

Both are used :class => "button"
7c42bc2b2720119ba03241fd0ea91515?d=identicon&s=25 Andres Coppola (peyu)
on 2017-03-02 22:30
Try to do it with some css, like this:

<div class="image-upload">
   <label for="file-input">
     <span> MyTextHere</span>
   </label>

   <%= f.file_field :image_url, id:"file-input" %>
</div>


And then in .css file pt something like this:


.image-upload > input
{
   display: none;
}
.image-upload > label{
  cursor:pointer;
}


I haven't tested this, but I think it could works...
This topic is locked and can not be replied to.