如何给simple_form标签赋予样式?

时间:2021-08-12 15:58:07

I'm trying to change the font-size and the spacing between the input box and label, in a form I've generated with the simple_form gem, 2.0.2. I'm sure there's a way to do this?

我试图改变输入框和标签之间的字体大小和间距,以我用simple_form gem 2.0.2生成的形式。我确定有办法做到这一点?

At present I have:

目前我有:

<%= f.input :comment, :input_html => { :wrap => :soft, :rows => 2}, :label => 'Type in box below:', :item_wrapper_class => 'type' %>

And in my css:

在我的CSS中:

    .type{
  font-size: 24px;
  margin-top: 15px;
}

I read in a post on this site that 'item_wrapper_class' would do the trick, but when I go to inspect element in Chrome, over the 'Type in box below:' part, it doesn't even pick up on the .type class, in my css - it just goes to the default label class, in bootstrap.

我在这个网站上的一篇文章中读到'item_wrapper_class'可以解决这个问题,但是当我去Chrome中检查元素时,通过下面的'输入框:'部分,它甚至没有找到.type类,在我的CSS中 - 它只是在bootstrap中进入默认标签类。

Any help would be appreciated, thanks.

任何帮助将不胜感激,谢谢。

2 个解决方案

#1


13  

This worked for me:

这对我有用:

<%= f.input :comment, :input_html => { :wrap => :soft, :rows => 2}, :label => 'Type in box below:', :label_html => { :class => 'type' } %>

#2


2  

Have you tried something like this?

你尝试过这样的事吗?

<%= f.input :comment, :input_html => { :wrap => :soft, :rows => 2}, :label => 'Type in box below:', wrapper_html: { class:  'type' } %>

#1


13  

This worked for me:

这对我有用:

<%= f.input :comment, :input_html => { :wrap => :soft, :rows => 2}, :label => 'Type in box below:', :label_html => { :class => 'type' } %>

#2


2  

Have you tried something like this?

你尝试过这样的事吗?

<%= f.input :comment, :input_html => { :wrap => :soft, :rows => 2}, :label => 'Type in box below:', wrapper_html: { class:  'type' } %>