Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/41.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
Html RoR中的图像叠加_Html_Css_Ruby On Rails_Graphics - Fatal编程技术网

Html RoR中的图像叠加

Html RoR中的图像叠加,html,css,ruby-on-rails,graphics,Html,Css,Ruby On Rails,Graphics,我想在RoR中将一个图像叠加到另一个图像上 在纯html中执行此操作很容易(从): 当我将代码放在一个单独的file.html文件中时,该代码对我有效。 然后在Rails中,我会: <div style="position: relative; left: 0; top: 0"> <%= image_tag "a.jpg", :style => "position:relative; top:0; left:0;" %> <%= image_tag

我想在RoR中将一个图像叠加到另一个图像上

在纯html中执行此操作很容易(从):


当我将代码放在一个单独的file.html文件中时,该代码对我有效。 然后在Rails中,我会:

<div style="position: relative; left: 0; top: 0">
  <%= image_tag "a.jpg", :style => "position:relative; top:0; left:0;" %>
  <%= image_tag "b.jpg", :style => "position:absolute; top:30; left:70; 
                                    border:thick solid blue;" %>
</div>

“位置:相对;顶部:0;左侧:0;”%>
“位置:绝对;顶部:30;左侧:70;
边框:深蓝色实心;“%>
但是第二个图像显示在第一个图像的旁边,没有任何偏移。将第二个图像边框添加到代码中,以检查样式是否已实际传递

你知道为什么Rails版本不起作用吗


ruby 1.9.3,rails 3.2,因为您复制的代码将第二个映像放在第一个映像旁边

试试看:

 <div style="position: relative; left: 0; top: 0;">
  <img src="a.jpg" style="position: relative; top: 0px; left: 0px;"/>
  <img src="b.jpg" style="position: absolute; top: 30px; left: 70px;"/>
 </div>

样本如下:

加上px,岩石就会晃动

在rails/ERB中表示:

<div style="position: relative; left: 0; top: 0">
  <%= image_tag "a.jpg", :style => "position:relative; top:0px; left:0px;" %>
  <%= image_tag "b.jpg", :style => "position:absolute; top:30px; left:70px; border:thick solid blue;" %>
</div>

“位置:相对;顶部:0px;左侧:0px;”%>
“位置:绝对;顶部:30像素;左侧:70像素;边框:深蓝色实心;”%>

你能不能用html类而不是
:style
,因为内联样式不是一个好的选择…在css
中使用像“first\u image”%>`和“first\u image”{position:relative;top:0;left:0;}
如果第一个代码有效,我看不出第二个代码无效的任何原因。确保第一个代码首先工作。您可以测试的另一件事是将它们放在同一个视图中,然后比较生成的html。
<div style="position: relative; left: 0; top: 0">
  <%= image_tag "a.jpg", :style => "position:relative; top:0px; left:0px;" %>
  <%= image_tag "b.jpg", :style => "position:absolute; top:30px; left:70px; border:thick solid blue;" %>
</div>