简体   繁体   English

如何更改 WTForm 上文本的颜色? (蟒蛇,HTML)

[英]How do I change the color of text on a WTForm? (python, html)

So I am trying to create a Flask app.所以我正在尝试创建一个 Flask 应用程序。

Here is a section of my html:这是我的 html 的一部分:

<div class = "card-body">
      <div>
         {{ form.hidden_tag() }}
         {{ render_field(form.email, class = "form-control") }}
         {{ render_field(form.password, class = "form-control") }}
         {{ render_field(form.remember_me, class = "form-control") }}
         {{ render_field(form.submit, class = "btn btn-primary") }}
      </div>

and here is my python file where I named the input fields:这是我命名输入字段的python文件:

from flask_wtf import FlaskForm
from wtforms import StringField, BooleanField, IntegerField, PasswordField, SubmitField, TextAreaField
from wtforms.validators import DataRequired, length, email, EqualTo


class LoginForm(FlaskForm):
    email = StringField("Email", validators = [DataRequired(), email()])
    password = PasswordField("Password", validators = [DataRequired()])
    remember_me = BooleanField("Remember Me")
    submit = SubmitField("Login")

I connected them through some other files and its all fine, all I need to do is change the color of the text in the python file.我通过一些其他文件将它们连接起来,一切都很好,我需要做的就是更改 python 文件中文本的颜色。 For example, lass LoginForm(FlaskForm):例如,lass LoginForm(FlaskForm):

  email = StringField("Email", validators = [DataRequired(), email()])

The "email" which shows on my form as the title of the input place, is currently black, how do I make it white?在我的表单上显示为输入位置标题的“电子邮件”目前是黑色的,我如何使它变成白色?

I altered the input place using the form control class and stuff, but am confused with the text above it because they are string in the python file.我使用表单控件类和东西更改了输入位置,但对其上方的文本感到困惑,因为它们是 python 文件中的字符串。

So for this you have to create one directory named " templates " and in that create one css file eg- style.css and in that you can do your styling.因此,为此您必须创建一个名为“ templates ”的目录,并在其中创建一个 css 文件 eg- style.css并且您可以在其中进行样式设置。 You can go through the documentation https://flask.palletsprojects.com/en/0.12.x/tutorial/css/您可以浏览文档https://flask.palletsprojects.com/en/0.12.x/​​tutorial/css/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM