是否仍然可以对表单进行布局和样式设置?专门将 label 和输入字段放在新行上,并可能将一些CSS应用于整个表单和表单的各个部分.解决方案每个django表单都有三种方法: as_p()as_ul()as_table() 请参见将表单输出为html 部分.您可以根据需要设置此输出的样式.如果您想进一步控制表单的html,请阅读同一文档的本部分.The Django UserCreationForm is very useful and easy to use functionally, however, it just throws everything onto the page so all the TextFields are in one line.Is there anyway to layout and style the form? Specifically to put labels and input fields on a new line and possibly make it possible to apply some CSS to the whole form and individual parts of the form. 解决方案 Every django form has three methods: as_p()as_ul()as_table()See the outputting forms as html section in the docs. You can style this output as you want.If you want even more control over form's html then read this section of the same documentation. 这篇关于Django-使用CSS样式化UserCreationForm的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 07-28 04:42