Elias7
Elias7

Reputation: 12861

How to style buttons in Ruby on Rails

Button is as follows:

    <%= render 'follow_form' if signed_in? %>

In follow_form:

    <%= render 'follow' %>

In follow.html.erb:

    <%= form_for current_user.relationships.build(:followed_id => @user.id),
         :remote => true do |f| %>
    <div><%= f.hidden_field :followed_id %></div>
    <div class="actions"><%= f.submit "Watch" %></div>
    <% end %>

How would I style that with CSS?

Upvotes: 2

Views: 12035

Answers (2)

Geoffrey Litt
Geoffrey Litt

Reputation: 160

You can simply pass parameters to the f.submit helper, including a class and/or ID, to enable the button to be styled by CSS. For example, you could put this in the ERB:

<div class="actions"><%= f.submit "Watch", :class => "button" %></div>

and then have a CSS class that applies to that, for example:

.button{
  color: #bbbbbb;
  width: 200px;
  height: 100px;
  /*add any other properties you want to style*/
}

Upvotes: 3

Vik
Vik

Reputation: 5961

Try :

<%= f.submit "Watch" , :style => 'padding-top: 14px', :class => 'class_name' %>

Upvotes: 3

Related Questions