Html 如何在rails中添加类和图标以形成_标记
我正在尝试将表单标记和字体添加到以下格式:Html 如何在rails中添加类和图标以形成_标记,html,css,ruby-on-rails,font-awesome,Html,Css,Ruby On Rails,Font Awesome,我正在尝试将表单标记和字体添加到以下格式: <%= form_tag(controller: "maps", action: "favorite", method: "post"%> <%= submit_tag "Favorite"%> 我试过这样做,但什么也没有发生。它看起来仍然像下图中的灰色按钮。我正在尝试替换图像中的绿色收藏夹按钮,该按钮也有一个很棒的字体图标 <%= form_tag(controller: "maps", action:
<%= form_tag(controller: "maps", action: "favorite", method: "post"%>
<%= submit_tag "Favorite"%>
我试过这样做,但什么也没有发生。它看起来仍然像下图中的灰色按钮。我正在尝试替换图像中的绿色收藏夹按钮,该按钮也有一个很棒的字体图标
<%= form_tag(controller: "maps", action: "favorite", method: "post")%>
<%= submit_tag "Favorite",html: { class: 'btn-u btn-u-lg rounded-4x btn-u-green' }%>
这是我的完整代码和图片:
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<!--Basic Table-->
<div class="panel panel-green margin-bottom-40">
<div class="panel-heading">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<div class = "name"></div>
</div>
<div class="panel-body">
<div id="map2" style='width: 568px; height: 365px;'></div>
<div class="row">
<div class="col-sm-12 text-center">
<button class="btn-u btn-u-lg rounded-4x btn-u-green" type="button"><i class="fa fa-check-circle" aria-hidden="true"></i> Check Availability</button>
<button class="btn-u btn-u-lg rounded-4x btn-u-green" type="button"><i class="fa fa-plus-circle" aria-hidden="true"></i> Add to Favorites</button>
<%= form_tag(controller: "maps", action: "favorite", method: "post")%>
<%= submit_tag "Favorite",html: { class: 'btn-u btn-u-lg rounded-4x btn-u-green' }%>
</div>
</div>
</div>
<table class="table paneltb">
</table>
</div>
<!--End Basic Table-->
</div>
</div>
×闭合
检查可用性
添加到收藏夹
对于可能偶然发现这一点的其他人,我认为不可能将字体很棒的图标与表单标签链接起来。我可以通过一个指向标签的链接来实现这一点 在上面Jermaine Subia询问的示例代码中,我认为它看起来是这样的:
<%= link_to(favorite_maps_path, method: "post") do %>
<i class="fa fa-heart" title="Favorite"></i>
<% end %>
以下是我刚刚实现的一些示例代码,我知道它们是有效的:
<%= link_to(user_jobs_path(user_job: {title: job.title, company: job.company, url: job.url, description: job.description, user_id: current_user}), method: "post") do %>
<i class="fa fa-heart" title="Save to my jobs"></i>
<% end %>
同样在上面的例子中,我向操作传递了许多参数,作为一种补充,您不应该需要
title
属性,我认为这只是当您将鼠标悬停在图标上时看到的文本。希望这能帮到别人 对于其他可能会偶然发现这一点的人,我认为不可能将字体很棒的图标与表单标签链接起来。我可以通过一个指向标签的链接来实现这一点
在上面Jermaine Subia询问的示例代码中,我认为它看起来是这样的:
<%= link_to(favorite_maps_path, method: "post") do %>
<i class="fa fa-heart" title="Favorite"></i>
<% end %>
以下是我刚刚实现的一些示例代码,我知道它们是有效的:
<%= link_to(user_jobs_path(user_job: {title: job.title, company: job.company, url: job.url, description: job.description, user_id: current_user}), method: "post") do %>
<i class="fa fa-heart" title="Save to my jobs"></i>
<% end %>
同样在上面的例子中,我向操作传递了许多参数,作为一种补充,您不应该需要
title
属性,我认为这只是当您将鼠标悬停在图标上时看到的文本。希望这能帮到别人 你安装了字体很棒的rails gem吗?是的,我安装了它,删除html:{}部分。试试这个@xiaocui,字体很棒的图标呢?你安装了字体很棒的rails gem吗?是的,我安装了它,删除html:{}部分。试试这个@xiaocui,字体很棒的图标呢?