如何在Rails中创建动态CSS? [英] How do I create dynamic CSS in Rails?

查看:165
本文介绍了如何在Rails中创建动态CSS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是使用Rails创建动态CSS的最好/最有效的方法。我在一个网站上开发一个管理区域,我希望用户能够自定义他们的个人资料的风格(主要颜色),这也将被保存。

what is the best/most efficient way of creating dynamic CSS with Rails. I am developing an admin area on a site, where I would like a user to be able to customize the style of their profiles(Colour mostly), which will also be saved.

您是否只需在css文件中嵌入ruby脚本?
您需要从css更改文件扩展名吗?

Would you just embed ruby script in the css file? Would you need to change the file extension from css?

谢谢。

推荐答案

目前有很多选项可以在rails中生成动态css。

Currently there is a lot of options to generate dynamic css in rails.

您可以使用

You can use less css - is an extension to CSS with extra features.

Gem less css - /github.com/metaskills/less-railsrel =nofollow noreferrer> Less css for rails 使用资产管道

Gem Less css for rails provides integration for Rails projects using the Less stylesheet language in the asset pipeline.

如果您使用twitter启动,您可以查看 less rails bootstrap

If you are using twitter bootstrap you may check this out less rails bootstrap.

可以使用一种或多种CSS扩展语言 Sass 来生成CSS。这是 Saas rails gem

Also you can use one more CSS extension language Sass for generating CSS. Here is a Saas rails gem.

查看 Rails中的动态CSS 将Rails资产转换为字符串博客文章和文章资产管道

Check out Dynamic CSS in Rails and Render Rails assets to string blog posts and article about Asset Pipeline

相关 SO 问题:

  • Best way to handle dynamic css in a rails app
  • Dynamic CSS in Rails asset pipeline, compile on fly
  • Rails: change CSS property dynamically?

这篇关于如何在Rails中创建动态CSS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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