【发布时间】:2020-02-02 06:39:40
【问题描述】:
通过在普通 HTML 中运行此代码,它也可以以样式运行。但是每当我在 django 中运行它时,它就会运行并只显示一个文本。我申请了../static/css/animate.css、../css/animate.css 和css/animate.css,但它们都没有工作。我通过提供 STATIC_ROOT 对 settings.py 进行了更改,但仍然只显示文本。
settings.py
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
views.py
def index(request):
return render(request, 'index.html');
主网址
urlpatterns = [
path('', include('app1.urls')),
path('admin/', admin.site.urls)
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
index.html
{% load static %}
<!-- Animate.css -->
<link rel="stylesheet" href="{% static '../static/css/animate.css' %}">
<!-- Icomoon Icon Fonts-->
<link rel="stylesheet" href="{% static '../static/css/icomoon.css' %}">
<!-- Simple Line Icons -->
<link rel="stylesheet" href="{% static '../static/css/simple-line-icons.css' %}">
<section id="fh5co-home" data-section="home" style="background-image: url(../static/images/W1.png);" data-stellar-background-ratio="0.5">
<div class="gradient"></div>
<div class="container">
<div class="text-wrap">
<div class="text-inner">
<div class="row">
<div class="col-md-8 col-md-offset-2 text-center">
<h1 class="to-animate">Welcome in the World of White Hats</h1>
<h2 class="to-animate">Your Problem with auto Solution</h2>
</div>
</div>
</div>
</div>
</div>
</section>
文件夹结构
【问题讨论】:
-
STATIC_URL 和 STATiC_ROOT 的设置是什么?
-
STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
-
我不是通过 StackOverflow 找到答案的,但感谢您的支持
标签: html css django python-3.x