Why does using an input group break the baseline alignment in bootstrap?

前端 未结 1 1248
天涯浪人
天涯浪人 2021-01-14 09:22

If I have a form with a label next to an input, in plain HTML, and both are inline (or inline block), then they are aligned by their baseline. But when using bootstrap and p

1条回答
  •  旧巷少年郎
    2021-01-14 10:06

    Because the input group is display: inline-table; and the label is outside the input-group. If you inspect the input-group-addon element, you see that it is set to display: table-cell; and vertical-align: middle;. If you move the label inside the input-group and style it same as the input-group-addon it lines up correctly.

    addon

    .

    .input-group label {
        padding: 4px;
        display: table-cell;
        vertical-align: middle;
    }
    

    http://jsfiddle.net/N62he/

    0 讨论(0)
提交回复
热议问题