简体   繁体   English

将标签复杂化到link_to

[英]Complex a tag to link_to

A designer gave me the following code snippet: 设计师给了我下面的代码片段:

      <a href="register_learner.html">
        <div class="service-block service-block-sea service-or">
          <div class="service-bg"></div>
          <i class="icon-custom icon-color-light rounded-x fa fa-user-plus"></i>
          <h2 class="heading-md">Register a Learner</h2>
        </div>
      </a>

which I am suppose to make into a single link_to. 我想将其制作成单个link_to。 Is this possible in Rails and if so a hint would be appreciated. 在Rails中是否可行,如果可以的话,将不胜感激。

Or maybe am I seeing it wrong? 还是我看错了? I tried to put the divs out and then put the link_to 'Register Learner', new learner_path in the middle of them but it was not working. 我试图将div放出,然后将link_to 'Register Learner', new learner_path放在其中,但是它没有用。

in rails you could do this like 在铁轨上,你可以这样做

 <%= link_to "register_learner" do %>
    <div class="service-block service-block-sea service-or">
      <div class="service-bg"></div>
      <i class="icon-custom icon-color-light rounded-x fa fa-user-plus"></i>
      <h2 class="heading-md">Register a Learner</h2>
    </div>
  <% end %>

http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to

EDIT - as an aside, putting divs inside a tags used to be frowned upon but is now acceptable practise, as long as there are no interactive elements inside the contents. 编辑-顺便说a只要在内容中没有交互元素,就可以将divs放在曾经被皱眉a标签中,但现在可以接受。 eg, don't put another link inside. 例如,不要在其中放置其他链接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM