Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python css文件没有';在Django应用程序中无法工作_Python_Html_Css_Django - Fatal编程技术网

Python css文件没有';在Django应用程序中无法工作

Python css文件没有';在Django应用程序中无法工作,python,html,css,django,Python,Html,Css,Django,当我在django应用程序中使用静态文件时,我发现了一个奇怪的问题:当我在css文件中使用body{}时,可以更改body的属性,当我使用div的id或类名时,css文件对div的属性不起作用,如下所示: base.html: <!DOCTYPE html> {% load staticfiles %} <html lang="zh-CN"> <head> <meta charset="utf-8"> <meta http-equiv="

当我在django应用程序中使用静态文件时,我发现了一个奇怪的问题:当我在css文件中使用body{}时,可以更改body的属性,当我使用div的id或类名时,css文件对div的属性不起作用,如下所示:

base.html:

<!DOCTYPE html>

{% load staticfiles %}

<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<title>{% block title %} Food {% endblock title %}</title>

<link rel="stylesheet" href="{% static "style/index.css" %}" media="screen"/>

</head>
 <body>
  <div class="sidebar">
  {% block sidebar %}

      {% endblock %}
  </div>
  <div class="content">
      {% block content %}
       <i>Delicious</i>
      {% endblock %}
  </div>

</body>
</html>

只有body{}可以生效。而其他像.sidebar{}和.body head{}这样的控件则无效。

您的
侧边栏和
块和
body head
div是空的

这是你的整个页面还是仅仅是一个例子


如果你能看到主体样式,我想css文件引用得很好。

检查样式表url是否正确指向css文件非常感谢。这只是因为我忘记了填充内容。很抱歉,我对内容不够熟悉,不能将其置为空。非常感谢你
{% extends "blog/base.html" %}

{% block title %} Food title{% endblock title %}
{% block content %}

<div class="body-head">
</div>

<div class="body-middle">
</div>

<div class="body-foot">
</div>

{% endblock content %}
body {
height: 100%;
width: 100%;
background-color: brown;

}
.sidebar{
    width: 100%;
    height: 10%;
    background-color: seagreen;
}
.body-head {
    width: 100%;
    height: 50%;
    background-color: sandybrown;
}