Django-crispy-forms input size

According to the django-crispy-form documentation , I can change the input width with the input-small class. But my shape always looks 100% wide:

enter image description here

Also, if I add css_class to the field, the size will remain in width: 100% ( .form-control )

I set the form as the 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 am updating the version. What's wrong?

+6
source share
1 answer
  • In the bootstrap3 class name for a small input field, input-sm
  • input-sm just sets the font size and height of the field; it has nothing to do with the width of the field.

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

+2
source

All Articles