15

您好,有人知道如何为 css 样式向 simple_form 提交按钮添加一个类。这是我尝试做的事情:

_form.html.erb

<%= simple_form_for(@drink) do |f| %>
 <%= f.submit "Add drink",:input_html =>{:class => "create"} %>
<%end%>

饮料.css.scss

.create {
    background-color:#2fd62f;
    -moz-border-radius:4px;
    -webkit-border-radius:4px;
    border-radius:4px;
    border:1px solid #dcdcdc;
    display:inline-block;
    color:#fafafa;
    font-family:arial;
    font-size:12px;
    font-weight:bold;
    padding:7px 24px;
    text-decoration:none;
    text-shadow:0px 0px 0px #70706f;
}.create:hover {
    background-color:#2fbf0f;
}.create:active {
    position:relative;
    top:1px;
}   
4

2 回答 2

36

<%= f.submit "Add drink", :class => "create" %>

于 2011-10-17T04:27:25.147 回答
1

在 rails 5 中执行以下操作

<%= f.button :submit, "Add drink", class: "create" %>
于 2017-06-20T12:22:39.390 回答