2012-04-13 75 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