是否可以使用styles.css编辑酥脆的表单?喜欢更改背景颜色等吗?因为我可以做我的工作。谢谢

发布于 2025-01-22 06:46:38 字数 1334 浏览 3 评论 0原文

我是研究Python Django的初学者,我正在尝试使用脆皮表格为我的网站创建一个登录页面。但是我无法控制它的样式,我想知道这是否可能,如果是,我该怎么做?谢谢。

这是Django HTML代码:


{% extends 'users/base.html' %}
{% load crispy_forms_tags %}
{% block content %}
{% load static %}
<link rel="stylesheet" href="{% static 'users/register.css' %}">

<div class="register-container">
    <form method="POST">
        {% csrf_token %}
        <fieldset class="form-group">
            <legend class="border-bottom mb-4">
                Create An Acount
            </legend>
            {{ form|crispy }}
        </fieldset>
        <div class="form-group">
            <button class="btn btn-outline-info" type="submit">
                Sign Up
            </button>
        </div>
    </form>
    <div class="border-top pt-3">
        <small class="text-muted">
            Already Have An Account? 
            <a class="ml-2" href="#">Log In</a>
        </small>
    </div>
</div>

{% endblock content %}

CSS: base.css

    transition: margin-left .5s;
    padding: 16px;
    background: rgb(255,255,255);
    background: radial-gradient(circle, 
              rgba(255,255,255,1) 0%, 
              rgba(33,208,178,1) 100%);
  } 

I am a beginner in studying Python Django and I am trying to create a login page for my website using crispy forms. But I can't control the styling of it, I am wondering if it is possible and if it is, how can I possibly do it? Thanks.

Here is the Django HTML codes:


{% extends 'users/base.html' %}
{% load crispy_forms_tags %}
{% block content %}
{% load static %}
<link rel="stylesheet" href="{% static 'users/register.css' %}">

<div class="register-container">
    <form method="POST">
        {% csrf_token %}
        <fieldset class="form-group">
            <legend class="border-bottom mb-4">
                Create An Acount
            </legend>
            {{ form|crispy }}
        </fieldset>
        <div class="form-group">
            <button class="btn btn-outline-info" type="submit">
                Sign Up
            </button>
        </div>
    </form>
    <div class="border-top pt-3">
        <small class="text-muted">
            Already Have An Account? 
            <a class="ml-2" href="#">Log In</a>
        </small>
    </div>
</div>

{% endblock content %}

CSS:
base.css

    transition: margin-left .5s;
    padding: 16px;
    background: rgb(255,255,255);
    background: radial-gradient(circle, 
              rgba(255,255,255,1) 0%, 
              rgba(33,208,178,1) 100%);
  } 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我做我的改变 2025-01-29 06:46:38

是的,您可以简单地添加JavaScript代码,将类添加到所需的输入字段中,然后可以为该类添加样式。

例如: -

# if you want to add styling to the username input then

# use this javascript
const inp_field = document.querySelector("#input_username"); # enter the id/class of that element
inp_field.classList.add("custom__css");
    
# css code
.custom__css {
    # whatever css you need
}

Yes its possible, you can simply add javascript code which adds class to desired input field and then you can add styling for that class.

For e.g :-

# if you want to add styling to the username input then

# use this javascript
const inp_field = document.querySelector("#input_username"); # enter the id/class of that element
inp_field.classList.add("custom__css");
    
# css code
.custom__css {
    # whatever css you need
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文