我在静态文件中创建了 CSS 文件
static
css
resume.css
在setting.py 中,我没有更改任何静态代码。
我在 view.py 中调用了 index.html 文件
每当我从 index.html 调用 resume.css 文件时。它不起作用,但是当我检查代码时,它显示了 resume.css 的正确路径。每当我运行代码时,我都没有收到任何错误。所以,我无法弄清楚这个问题
这是HTML代码:
<!DOCTYPE html>
<html lang="en">
<head>
<title> resume</title>
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
{% load static %}
<link rel="stylesheet" href="{% static 'css/resume.css' %}">
</head>
<body>
<header class="w3-hide-small main-header">
<h1 class=" header"> welcome to my page </h1>
</header>
<header class="w3-show-small w3-hide-medium w3-hide-large main-header">
<h1 class="w3-center header-for-small"> welcome to <br/>my page </h1>
</header>
</body>
</html>
这是CSS代码:
.main-header{
background-color: antiquewhite;
}
.header{
margin-top: 0px;
margin-left: 50px;
font-size: 25px;
text-transform: uppercase;
color: blue;
text-shadow: 2px 2px;
padding: 15px;
margin-bottom: 0px;
}
.header-for-small{
margin-top: 0px;
font-size: 20px;
font-weight:bold;
text-transform: uppercase;
color: blue;
padding: 15px;
font-family: fontawesome;
margin-bottom: 0px;
}
视图.py
def index(request):
return render(request, 'Web/index.html')
这个 url.py 是由 python 创建的
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('Web.urls'))
]
这个 url.py 是我在项目或应用程序中创建的
urlpatterns = [
path('', views.index, name='index'),
]