【问题标题】:Make a link as a button in rails spree在 rails spree 中将链接作为按钮
【发布时间】:2016-04-23 07:22:58
【问题描述】:

我正在开发一个 rails spree 应用程序。

我想让我的链接作为一个按钮工作。这是链接的外观。

<li>
  <%= link_to Spree.t(:forgot_password), spree.recover_password_path %>
</li>

如何将其设为 Button 并向该按钮添加一些类?

【问题讨论】:

    标签: html css ruby-on-rails spree


    【解决方案1】:

    如果您想生成 HTML 按钮,而不是超链接,请将您的 link_to 更改为 button_to

    <%= button_to Spree.t(:forgot_password), spree.recover_password_path %>
    

    这将生成一个带有单个按钮的表单,将用户带到给定的 URL。

    但是,如果您想简单地设置链接作为按钮,请使用 CSS。 CSS 规则将取决于您的风格。因此,只需 Google 并选择适合您需求的样式。

    如果您的模板使用 Twitter Bootstrap,您只需添加 btnbtn-* 类即可将其设置为按钮样式。

    <%= link_to Spree.t(:forgot_password), spree.recover_password_path, class: 'btn btn-default' %>
    

    【讨论】:

    • 该死!我正在这样做,但在上课前错过了comma。第二个选项是我需要的。谢谢
    猜你喜欢
    • 2018-03-09
    • 2011-09-09
    • 1970-01-01
    • 2015-05-13
    • 2020-11-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-30
    相关资源
    最近更新 更多