Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/62.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
Css 我将如何内联设置此样式?_Css_Ruby On Rails - Fatal编程技术网

Css 我将如何内联设置此样式?

Css 我将如何内联设置此样式?,css,ruby-on-rails,Css,Ruby On Rails,我如何给#{self.o_cord.name}和#{self.o_product.full_name}一个内联样式,使它们的背景颜色为橙色?它们在一个.rb文件中,我不确定这是否会改变什么。提前谢谢 if self.o_connection.dongle? return "Plug the #{self.o_cord.name} end of the #{self.o_product.full_name} into the #{self.i_product.full_name}." 我会

我如何给#{self.o_cord.name}和#{self.o_product.full_name}一个内联样式,使它们的背景颜色为橙色?它们在一个.rb文件中,我不确定这是否会改变什么。提前谢谢

if self.o_connection.dongle? 
  return "Plug the #{self.o_cord.name} end of the #{self.o_product.full_name} into the #{self.i_product.full_name}."

我会将字符串保留在您的模型之外,而是调用o_connection.dongle?在你看来。然后在您的视图中,您可以简单地通过css将关键字包装成一个范围和样式

视图:


Haml内联css示例:

= f.text_area :short_description, :style =>'background-color:'orange';'
雇员再培训局

背景色:'橙色';'%>
如中所述,要使用哪些选择器和属性?是的,我不确定如何在return语句中使用内联CSS的语法
span.info-label {
  background-color: 'orange';
}
= f.text_area :short_description, :style =>'background-color:'orange';'
<%= f.text_field :short_description, :style => 'background-color:'orange';' %>