django-crispy-forms输入大小 [英] django-crispy-forms input size

查看:450
本文介绍了django-crispy-forms输入大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据)。所以首先要确保你的屏幕分辨率足以满足 lg 。尝试 col-sm - *


According with django-crispy-form documentation, I will be able to change input width with class input-small. But my form always looks with width at 100%:

Also, If I add css_class to Field the size remains at width:100% ( .form-control )

I have set form as documentation explains:

class LoginForm(forms.Form):
    usuari = forms.CharField( help_text = u'Codi Usuari')
    paraula_de_pas = forms.CharField( help_text = u'Paraula de pas')

    # Uni-form
    helper = FormHelper()
    helper.form_class = 'form-horizontal'
    helper.label_class = 'col-lg-2'  
    helper.field_class = 'col-lg-8'  
    helper.layout = Layout(
        PrependedText('usuari', 
                      '<span class="glyphicon glyphicon-user"></span> ',  
                      css_class='input-small'),
        PrependedText('paraula_de_pas', 
                      '<span class="glyphicon glyphicon-asterisk"></span> ', 
                      css_class='input-small'),
        FormActions(
            Submit('save_changes', 'Entrar-hi', css_class="btn-primary"),
        )
    )

In settings:

CRISPY_TEMPLATE_PACK="bootstrap3"

I'm up to date version. What is wrong?

解决方案

  • In bootstrap3 class name for small input box is input-sm
  • input-sm just sets size of the font and height of the field, it has nothing to do with field width.

form-horizontal, col-lg-2 and col-lg-8 make horizontal layout for the form (http://getbootstrap.com/css/#forms-horizontal). So first of all make sure your screen resolution to enough for lg. Try col-sm-*

这篇关于django-crispy-forms输入大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆