gpt4 book ai didi

python - Django 投票应用程序 : Background Image Not Loading

转载 作者:行者123 更新时间:2023-12-05 06:55:20 24 4
gpt4 key购买 nike

我正在学习 Django 并构建第一个测试投票应用程序,但遇到了背景图像问题。绿色文本有效,但添加背景图像没有任何作用(背景只是白色)。知道为什么这不能正常工作吗?

背景图片C:\Users\xxx\Python\Django\mysite\polls\static\polls\images\sample123.jpg

CSS样式:C:\Users\xxx\Python\Django\mysite\polls\static\polls\style.css

li a {
color: blue;
}

body {
background: url('C:\Users\xxx\Python\Django\mysite\polls\static\polls\images\sample123.jpg');
background-repeat: no-repeat;
}

索引 HTML:C:\Users\xxxx\Python\Django\mysite\polls\templates\polls

{% load static %}

<link rel="stylesheet" type="text/css" href="{% static 'polls/style.css' %}">

{% if latest_question_list %}
<ul>
{% for question in latest_question_list %}
<li><a href="{% url 'polls:detail' question.id %}">{{ question.question_text }}</a></li>
{% endfor %}
</ul>
{% else %}
<p>No polls are available.</p>
{% endif %}

最佳答案

这应该可以解决问题

body {
background: url('/static/images/sample123.jpg');
background-repeat: no-repeat;
}

关于python - Django 投票应用程序 : Background Image Not Loading,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65402732/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com