CSS规则未得到应用

时间:2014-04-12 18:48:01

标签: html css django nginx

由于某些原因,我的CSS规则未被应用。我知道css页面已经找到并加载到浏览器中。只是规则没有被应用。我已经尝试过执行h1规则,但我的规则并未应用于网页。我在ubuntu 12.04服务器上使用uwsgii和nginx。我已经收集了我的静态,重新启动的uwsgi和nginx,我已经改变了规则,我已经添加了!重要的是,我错过了一些东西而且我不知道它是什么。任何帮助将不胜感激。

目前我的css / base.css看起来像这样 - 我也尝试过将颜色改为红色但不是。

.evil {
    color: #c5e3bf;
}

我的基本模板 - 看起来像这样:

<!DOCTYPE html>
<html>
<head>
    <title>{% block sub_title %}{% endblock %} Awesome title</title>
    {% load staticfiles %}
    <link rel="stylesheet/css" type="text/css" href='{% static "css/base.css" %}'>
    <script type="text/javascript" src="{% static 'jquery-2.1.0.js' %}"></script>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.js"></script>
    <script type="text/javascript" src="{% static 'Underscore.js' %}"></script>
    <script type="text/javascript" src="{% static 'Restangular.js' %}"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.7/angular-route.js"></script>
    <script src="{% static 'js/ng-sign-in/app.js' %}"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>


    <body>
        <span class="evil">Punch something, you know you wanna. Just do it.</span>
    </body>
</html>

更新:我注释掉了所有脚本,只留下了

<link rel="stylesheet/css" type="text/css" href='/static/css/base.css'>

仍然没有应用规则。

更新:从在nginx上运行更改为运行localhost - 仍然没有运气 我的设置:

STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_URL = '/static/'

我的网址:

from django.conf.urls import patterns, include, url
from django.contrib import admin
from django.views.generic import TemplateView
from django.conf import settings
from django.conf.urls.static import static

admin.autodiscover()

urlpatterns = patterns('',     
    url(r'^admin/', include(admin.site.urls),     
    url(r'^$', HomeView.as_view(), name='home'),
) + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) # this was added in per request -- notta. 

1 个答案:

答案 0 :(得分:0)

尝试在urls.py中添加+ static(settings.STATIC_URL,document_root = settings.STATIC_ROOT):

  

urlpatterns = patterns(&#39;&#39;,#Your URLS) + static(settings.STATIC_URL,document_root = settings.STATIC_ROOT)