Heroku弄乱了样式 [英] Heroku messes up styles

查看:88
本文介绍了Heroku弄乱了样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将我的应用程序上传到了heroku,然后突然一切都改变了,文本在左右方向上随机对齐,而在我自己的服务器中,一切都在中间,就像我说的那样.

这是怎么回事?

链接到页面,以便您查看发生了什么事情: https://harjutus2.herokuapp.com

我使它在css文件中以及在每个p b和h2元素中居中对齐,以使其正常运行.再加上我的链接应该是蓝色的,但是突然也消失了.

解决方案

您的样式对我来说很好!


资产

您应该了解 Heroku对样式的处理.在部署应用程序之前,您必须先precompile您的资产.这样做的原因是使应用程序具有一致的感觉,并减少了Heroku测功机上的负载

设置方法如下:

#config/environments/production.rb
config.serve_static_assets = true
config.assets.compile = true

要部署到Heroku时,只需运行:

rake assets:precompile RAILS_ENV=production

这将预先编译您的样式,从而使它们在Heroku&上保持一致.本地

I uploaded my app to heroku and suddenly everything is just changed, text is randomly aligned left and right while in my own server it's all in the middle just like I say'd it to.

What is going on with it?

Link to page so you can see whats going on: https://harjutus2.herokuapp.com

Edit: I have it aligned middle in css files and also in every p b and h2 element out of frustration to get it work. Plus my links are supposed to be colored blue but that's suddenly gone also.

解决方案

Your styles look good to me!


Assets

There's something you should know about Heroku's handling of styles. You have to precompile your assets before you deploy the app. Reason for this is to give the app a consistent feel, and reduces load on the Heroku dynos

Here's how to set it up:

#config/environments/production.rb
config.serve_static_assets = true
config.assets.compile = true

When you want to deploy to Heroku, you just need to run:

rake assets:precompile RAILS_ENV=production

This will precompile your styles, allowing you to keep them consistent on Heroku & locally

这篇关于Heroku弄乱了样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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