CSS在heroku看起来不同 [英] CSS is looking different on heroku

查看:178
本文介绍了CSS在heroku看起来不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如你应该在下面的图片中看到的,我的本地主机站点上的css在顶部比在heroku上更好地隔开。



以前有人有这种类型的问题。您可以在此页面上查看最佳



我通过在我的计算机上本地预编译资源,然后将它们推送到Heroku来修复我的应用程序中的问题。



预编译资产:

  RAILS_ENV = rake assets:precompile 

将更改添加/提交到git存储库:

  git add public / assets 
git commit -mvendor compiled assets
  git push -f heroku heroku-assetpipeline:master 


As you should see in the images below, the css on my local host site is spaced much better at the top than it is on heroku.

Has anyone had this type of problem before. You can see it best on this page http://pltcpal.herokuapp.com/forums/

I'm using Twitter bootstrap, which recommends adding

`padding-top: 40px;` 

to body if using the top nav bar. Somehow it's not working...

解决方案

The problem is related to the handling of the asset pipeline on Heroku. There are several ways on how this can be handled, see http://devcenter.heroku.com/articles/rails31_heroku_cedar

I fixed the issue in my application by pre-compiling the assets locally on my machine and then pushing them to Heroku.

Pre-compile the assets:

RAILS_ENV=production bundle exec rake assets:precompile

Add/commit the changes to git repository:

git add public/assets
git commit -m "vendor compiled assets"

To be safe I tested the whole thing on a local branch on my machine first which I pushed to Heroku using the following command (Heroku normally ignores all branches except the master branch, thus the trick):

git push -f heroku heroku-assetpipeline:master

这篇关于CSS在heroku看起来不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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