2013-07-06 13 views
5

hinzufüge Ich verwende das Rails-Framework mit HAML und ich habe Bootstrap-Setup. Wie würde ich die Feldeingaben getrennt formatieren? Ich möchte, dass das Eingabefeld für Name 60% des linken Bildschirmbereichs und die Eingabe für den Preis 25% des Bildschirms und Float rechts ist.Wie man Styling zu einer einzelnen Eingabe in einem form_for

Ich denke, ich frage, wie füge ich Klassen zu einzelnen Eingaben in einer Form_for. Dank

= form_for @product,:url => products_path, :html => { :id => "fileupload", :multipart => true } do |f| 
    %p 
    = f.label :name 
    = f.text_field :name # i want to format this 
    %p 
    = f.label :price 
    = f.text_field :price 

Antwort

16

Sie eine Klasse für jede Form Helfer hinzufügen und CSS verwenden, um es zu formatieren:

= f.text_field :name, class: 'your_class' # i want to format this 

von Ursache Sie können auch eine Art Option direkt eingestellt, aber es ist zu trennen Inhalt empfohlen und Styling. Also nicht

= f.text_field :name, style: 'float: left; width: 60%; display: block' # i want to format this 
+0

Danke für die Antwort! Ich kann dich für weitere 3 Minuten nicht korrekt markieren. –