2013-08-17 55 views
0

我該如何給#{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}." 
+0

如我n,使用哪些選擇器和屬性? – Goodsoup

+0

是的,我不確定如何將內聯CSS放入return語句的語法 –

回答

0

我會保持你的模型的字符串,而不是調用o_connection.dongle?從你的角度來看。然後在你看來,你可以簡單地通過css將關鍵字包裝成一個範圍和樣式。

檢視:

<% if SomeClass.o_connection.dongle? %> 
    <p>Plug the <span class="info-label"><%= self.o_cord.name %></span> end of the <span class="info-label"><%= self.o_product.full_name %></span class="info-label"> into the <span><%= self.i_product.full_name %></span>.</p> 

CSS:

span.info-label { 
    background-color: 'orange'; 
} 
0

Haml的內聯的CSS實施例:

= f.text_area :short_description, :style =>'background-color:'orange';' 

ERB

<%= f.text_field :short_description, :style => 'background-color:'orange';' %>