How do I left align these Bootstrap form items?

后端 未结 6 494
無奈伤痛
無奈伤痛 2021-02-03 17:50

I\'m using Bootstrap for the first time, and am having a lot of trouble aligning this form-horizontal to the left.

The list items are horizontal, as they should be, but

相关标签:
6条回答
  • 2021-02-03 18:16

    "pull-left" is what you need, it looks like you are using Bootstrap 2, I am not sure if that is available, consider bootstrap 3, unless ofcourse it is a huge rework! ... for Bootstrap 3 but you need to make sure you have 12 columns in each row as well, otherwise you will have issues.

    0 讨论(0)
  • 2021-02-03 18:18

    If you are saying that your problem is how to left align the form labels, see if this helps:
    http://jsfiddle.net/panchroma/8gYPQ/

    Try changing the text-align left / right in the CSS

    .form-horizontal .control-label{
        /* text-align:right; */
        text-align:left;
        background-color:#ffa;
    }
    

    Good luck!

    0 讨论(0)
  • 2021-02-03 18:21

    I was having the exact same problem. I found the issue within bootstrap.min.css. You need to change the label: label {display:inline-block;} to label {display:block;}

    0 讨论(0)
  • 2021-02-03 18:22

    Just add style="text-align: left" to your label.

    0 讨论(0)
  • 2021-02-03 18:37

    Just my two cents. If you are using Bootstrap 3 then I would just add an extra style into your own site's stylesheet which controls the text-left style of the control-label.

    If you were to add text-left to the label, by default there is another style which overrides this .form-horizontal .control-label. So if you add:

    .form-horizontal .control-label.text-left{
        text-align: left;
    }
    

    Then the built in text-left style is applied to the label correctly.

    0 讨论(0)
  • 2021-02-03 18:39

    Instead of altering the original bootstrap css class create a new css file that will override the default style.

    Make sure you include the new css file after including the bootstrap.css file.

    In the new css file do

    .form-horizontal .control-label{
       text-align:left !important; 
    }
    
    0 讨论(0)
提交回复
热议问题