Rails:使用 simple_form 并集成 Twitter Bootstrap [英] Rails: Using simple_form and integrating Twitter Bootstrap

查看:53
本文介绍了Rails:使用 simple_form 并集成 Twitter Bootstrap的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建一个 rails 应用程序,而 simple_form 看起来是一个非常有用的 gem.问题是我使用 twitter bootstrap css 来做样式,而 simple_form 不允许你指定 html 的布局.

I'm trying to build a rails app and simple_form looks to be a really useful gem. Problem is that I am using twitter bootstrap css to do the styling and the simple_form doesn't allow you to specify the layout of the html.

谁能告诉我如何使 simple_form html 符合 bootstrap css 想要的格式?

Can anyone tell me how I can conform the simple_form html into the format bootstrap css wants?

推荐答案

注意:此答案仅适用于 SimpleForm <2.0

config/initializers/simple_form.rb 开始:

SimpleForm.form_class = nil
SimpleForm.wrapper_class = 'clearfix'
SimpleForm.wrapper_error_class = 'error'
SimpleForm.error_class = 'help-inline'

然后在标签元素和输入之间缺少空格,您可以添加:

Then there's space missing between the label element and the input, which you can add with this:

label {
  margin-right: 20px;
}

可能还有更多,但这是一个开始.

There's probably more, but it's a start.

这篇关于Rails:使用 simple_form 并集成 Twitter Bootstrap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆