【问题标题】:How do I turn off auto-update on static files? in django (python)如何关闭静态文件的自动更新?在 django (python)
【发布时间】:2020-07-18 17:37:47
【问题描述】:

我想改变 css。当我更改 oncklick 函数的 continer 高度时,1 秒后返回相同的大小,并且当我在 1 秒内出现错误控制台刷新并且我看不到时。如何修复?我关闭了 livereload 插件。它会在 1 秒内刷新所有内容。

当我在 css 崩溃后将 {% now "U" %} 删除到 css 链接 rel 并且不起作用时,为什么?这是问题吗?

这是我的代码--->

base.html

<!DOCTYPE HTML>

<html>
<head>
    <title>home</title>
</head>

<link rel="stylesheet" type="text/css" href="/static/css/style.css?{% now "U" %}" />


<body>


{% block content %}
{% endblock %}

<script src="/static/js/homescript.js"></script>
</body>
</html>

home.html

{% extends 'base.html' %}
<link rel="stylesheet" type="text/css" href="/static/css/style.css?{% now "U" %}" />

{% block content %}

    <form action = '' method="post" novalidate="novalidate">
        {% csrf_token %}
        <div class="continer">
        {% for field in form %}
        {{ field.label_tag }}
        {{ field }}
        {{ field.errors }}
        {% endfor %}
        <input type="submit" name="register" id="btn" onClick = "document.querySelector('#continer').style.height = '200px';">
        </div>
    </form>

{% endblock %}

style.css

@import url("//cdn.web-fonts.ge/fonts/bpg-glaho-arial/css/bpg-glaho-arial.min.css");

html,body{
    background-image: url("../img/test.jpg") ;
    background-position: center center;
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-attachment: fixed;
    padding: 0;
    margin: 0;
}

.continer {
    position: absolute;
    width: 300px;
    height:400px;
    background-color: blue;
}

.inp{
    margin: 3px;
    margin-left: 57px;
    width: 180px;
    height: 20px;
    border-radius: 5px;
    border: none;
    outline: none;

}

input,label {
    display:block;
    font-family: "BPG Glaho Arial", sans-serif;
    text-align: center;

}

.btn{
    margin-bottom: 20px;
}

.errorlist{
    background-color: red;
    border-radius: 2px;
    width: 220px;
    list-style-type: none;
    margin-left: 20px;
    color:white;
    text-align: center;

}
.errorlist li{
    padding-right: 28px;
    font-family: "BPG Glaho Arial", sans-serif;

}

【问题讨论】:

    标签: javascript python html css django


    【解决方案1】:

    将link标签放在base.html的head标签中

    在 home.html 中删除这一行

    <link rel="stylesheet" type="text/css" href="/static/css/style.css?{% now "U" %}" />
    

    最重要的是,在 home.html 的这一行中:

    <input type="submit" name="register" id="btn" onClick = "document.querySelector('#continer').style.height = '200px';">
    

    不是

    #container
    

    是的

    .container
    

    类名可以通过(.)访问,id名可以通过(#)访问

    所以将该行替换为:

    <input type="submit" name="register" id="btn" onClick = "document.querySelector('.continer').style.height = '200px';">
    

    【讨论】:

      猜你喜欢
      • 2020-12-11
      • 2013-07-20
      • 1970-01-01
      • 1970-01-01
      • 2021-01-17
      • 1970-01-01
      • 2020-09-20
      • 2018-05-28
      • 1970-01-01
      相关资源
      最近更新 更多