好的,所以我已经安装了 django-registration 应用程序,并且对于注册功能,我为电子邮件添加了一个小部件来制作占位符:
email = forms.EmailField(label=_("E-mail"),
widget=forms.TextInput(attrs={'placeholder': 'Your Email'}))
我更喜欢使用占位符,而不是标签。
现在,我的问题是:如何设置占位符的样式?添加一些颜色,更改占位符大小和字体等 谢谢
最佳答案
你可以做到这一点。
email = forms.EmailField(label=_("E-mail"),
widget=forms.TextInput(attrs={'placeholder': 'Your Email', 'class':'your_css_code'}))
关于Django - 如何设置表单字段占位符的样式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22271011/