2012-04-13 78 views
0

按钮如下:如何式按键在Ruby on Rails的

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

在follow_form:

<%= render 'follow' %> 

在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 %> 

我会怎样风格与CSS?

回答

3

你可以简单的参数传递给f.submit帮手,其中包括一个类和/或ID,以便能够通过CSS设置样式的按钮。例如,你可以把这个再培训局:

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

,然后有一个适用于,例如CSS类:

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

非常感谢! – Elias7 2012-04-13 07:26:04

3

尝试:

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

如果我试图款式颜色是什么,大小,圆edges..etc ..? TY – Elias7 2012-04-13 07:01:31

+1

增加样式:'color:#FFF; fonst-size:12px;'或者将类变为css并添加class_name。 – Vik 2012-04-13 07:02:52