如何更改输入字段中的文本大小?

Jam*_*ull 0 django django-forms

我正在尝试将文本输入的字体大小设置为在移动设备上查看时更大.为此,我为widget小部件添加了font-size属性,但它对输入的文本没有任何影响.

class MyMobileForm(forms.Form):

    answer = forms.CharField(label="Answer",
        widget=forms.TextInput(attrs={'autofocus': 'autofocus',
                                      'autocomplete': 'off',
                                      'size': '40',
                                      'font-size': 'xx-large',
                                      }))
Run Code Online (Sandbox Code Playgroud)

font-size属性只影响标签,所以我做错了什么?

cat*_*ran 6

font-size是一种风格属性:

    widget=forms.TextInput(attrs={'autofocus': 'autofocus',
                                  'autocomplete': 'off',
                                  'size': '40',
                                  'style': 'font-size: xx-large',
                                  })
Run Code Online (Sandbox Code Playgroud)

但是使用真正的CSS代替ad-hoc样式要好得多.将class属性设置为窗口小部件,然后在<style>外部.css文件的标记中定义规则.