Rails Active Admin css 与 Twitter Bootstrap css 冲突 [英] Rails Active Admin css conflicting with Twitter Bootstrap css

查看:31
本文介绍了Rails Active Admin css 与 Twitter Bootstrap css 冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 Rails 资产管道有点陌生,所以我可能做错了什么.我正在尝试将 Active Admin 用于我的后端,并将 twitter bootstrap css 用于我的前端应用程序.

I'm somewhat new to the Rails asset pipeline so I might be doing something wrong. I'm trying to use Active Admin for my backend and twitter bootstrap css for my front end application.

我将 bootstrap.css 添加到 /app/assets/stylesheets 然后还添加了:

I added the bootstrap.css to /app/assets/stylesheets then also added:

//= require bootstrap

到 application.css - 然后我在本地对资产进行了预编译

to application.css - then I did a precompile of the assets locally

它似乎工作正常,但有些样式并没有完全通过,我认为这是因为活动管理员的 css 覆盖了它.

It seems to work fine but some of the styling isn't coming through exactly and I think it's because active admin's css is overriding it.

我的理解是应用程序将 css 资产编译为应用程序 css 公共资产,并且应用程序在运行时使用该文件.

My understanding is that the application compiles the css assets into the application css public asset and the application uses that file when running.

我需要以某种方式将两者分开并使其使用 twitter bootstrap css 作为前端的主要 css,并可能告诉它不要使用 active admin's css 文件在前端.

I need to somehow separate the two and make it use twitter bootstrap css as the main css on the front end and maybe tell it not to use active admin's css files on the front end.

最好的方法是什么?

推荐答案

您是否看过有关使用 ActiveAdmin 的 RailsCasts 视频?在视频中,Ryan 向您展示了如何防止 ActiveAdmin CSS 踩到您的主应用 CSS.

Have you watched the RailsCasts video on using ActiveAdmin? In the video, Ryan shows you how to prevent the ActiveAdmin CSS from stepping on your main app CSS.

http://railscasts.com/episodes/284-active-admin

将视频中的信息转化为答案

Moving info from Video into answer

在 application.css 中删除:

In the application.css you remove:

*= require_tree .

对于 rails 4,Jiten K 建议将其添加到 production.rb:

For rails 4, Jiten K suggests adding this to production.rb:

config.assets.precompile += ['active_admin.css']

然而,对那个 SO 答案的评论之一说这是不需要的.到目前为止我还不需要它.

However one of the comments on that SO answer says this is not needed. I have not needed it so far.

这篇关于Rails Active Admin css 与 Twitter Bootstrap css 冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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