Rails 3正确的image_tag转换

时间:2013-07-12 04:09:13

标签: javascript css ruby-on-rails ruby-on-rails-3 parallax

我正在尝试将视差效果代码转换为在Rails 3应用上运行。我无法让它运行所以我想知道我是否正确转换了这段代码。每组中的第一行是原始代码。每组中的第二行是我的转换。谁能告诉我这是不是正确?

<article class="slide" id="showcasing" style="background:   url('backgrounds/landscape.png') repeat-x top center;">
<%= image_tag("backgrounds/landscape.png", :class => "slide", :id => "showcasing", :style => "background: repeat-x top center") %>

<img class="asset left-30 sp600 t120 z1" src="slides/scene1/macbook.png" />
<%= image_tag("slides/scene1/macbook.png", :class => "asset: left-30 sp600 t120 z1") %>

<article class="slide" id="ideas" style="background: url('backgrounds/aqua.jpg') repeat-x top center;">
<%= image_tag("backgrounds/aqua.jpg", :class => "slide", :id => "ideas", :style => "background: url('backgrounds/aqua.jpg') repeat-x top center") %>

<img class="asset left-480 sp600 t260 z1" src="img/slides/scene2/left.png" />
<%= image_tag("slides/scene2/left.png", :class => "asset left-480 sp600 t260 z1") %>

<img class="asset left-210 sp600 t213 z2" src="img/slides/scene2/middle.png" />
<%= image_tag("slides/scene2/middle.png", :class => "asset left-210 sp600 t213 z2") %>

<img class="asset left60 sp600 t260 z1" src="img/slides/scene2/right.png" />
<%= image_tag("slides/scene2/right.png", :class => "asset left60 sp600 t260 z1") %>

1 个答案:

答案 0 :(得分:0)

拥有<article>代码的所有人都不对,因为image_tag只会产生<img />代码。您应该使用image_path来生成网址并将其放入style="background: url()"image_path API)。

其他代码应该是:

<%= image_tag("slides/scene1/macbook.png", :class => "asset left-30 sp600 t120 z1") %>