Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 向表单元素添加样式_Ruby On Rails_Haml_Styling_Form For - Fatal编程技术网

Ruby on rails 向表单元素添加样式

Ruby on rails 向表单元素添加样式,ruby-on-rails,haml,styling,form-for,Ruby On Rails,Haml,Styling,Form For,似乎找不到这个问题的答案-在rails表单_中为元素添加样式或类样式的haml语法是什么 我处理的代码是 .row.form .threecol .sevencol = form_for @article do |a| %h3= a.label "title" = a.text_field :title %h3= a.label "description" = a.text_area :description %h

似乎找不到这个问题的答案-在rails表单_中为元素添加样式或类样式的haml语法是什么

我处理的代码是

.row.form
.threecol
.sevencol
    = form_for @article do |a|
      %h3= a.label "title"
      =    a.text_field :title 
      %h3= a.label "description"
      =    a.text_area :description
      %h3= a.label "body"
      =    a.text_area :body
      %br/
      =  a.submit "Post Article"
 .twocol.last
我想给文本区域描述元素添加一个样式。 我已经尝试过了(新描述是类样式)

但两者都未能编译。
有人能帮助解决这个(希望是微不足道的)问题吗

text\u区域是一种采用(对象、方法和选项)的方法(http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#method-i-文本(U区)

当您将它附加到表单对象时,您将保留该对象,使其成为文本区域(方法,选项={})


太好了,谢谢你。逐渐理解语法。对我来说,添加的内容需要格式化为rails哈希?可能有助于纠正被语法弄糊涂的其他读者。
= a.text_area.new_desc :description
= a.text_area { :style ... } :description
= a.text_area :description, class: "description"
= a.text_area :description, class: "description", style: "font-size: 45"