【问题标题】:How to move this image 2 pixels down? Syntax reccommendation如何将此图像向下移动 2 个像素?语法推荐
【发布时间】:2014-08-04 14:57:47
【问题描述】:

我有一个图像,我试图将其向下移动两个像素。这似乎很容易,但我不能完全正确地理解语法。下面是我的图片的代码。

= link_to("...with <img src='#{widget_logo_url}' border=0/>   
  Code", "http://website.net", :target => "_blank", :style => "margin-right:11px;")

我尝试了一些变体来移动这张图片,但它不起作用。这是我尝试过的:

= link_to("...with <img src='#{widget_logo_url}' border=0 margin-bottom:-2px/>   
  Code", "http://website.net", :target => "_blank", :style => "margin-right:11px;")

 = link_to("...with <img src='#{widget_logo_url}' border=0 "margin-bottom:-2px">   
  Code", "http://website.net", :target => "_blank", :style => "margin-right:11px;")

 = link_to("...with <img src='#{widget_logo_url}' border=0 margin-bottom:"-2px">   
  Code", "http://website.net", :target => "_blank", :style => "margin-right:11px;")

我查看了 link_to 参数并尝试修改 :style 标记,但它会将整个链接作为一个整体移动。一些帮助会很棒,因为我真的很想继续前进。谢谢。

【问题讨论】:

  • 试用link_to 的块版本(在文档中显示)

标签: ruby-on-rails


【解决方案1】:

根据这个documentation,您也许可以执行以下操作:

link_to "http://website.net", {:target => "_blank", :style => "margin-right:11px;"} do
  # place here your <img> tag, or whatever you want wrapping up by your link
end

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-08
    • 1970-01-01
    • 2020-07-10
    • 1970-01-01
    • 2013-04-23
    • 1970-01-01
    • 2011-11-01
    相关资源
    最近更新 更多