Vertical Align text in a Label

前端 未结 14 1668
攒了一身酷
攒了一身酷 2021-02-06 20:27

I have been asked to vertically align the text in the labels for the fields in a form but I don\'t understand why they are not moving. I have tried putting in-line styles using

14条回答
  •  青春惊慌失措
    2021-02-06 20:56

    Vertical alignment only works with inline or inline-block elements, and it's only relative to other inline[-block] elements. Because you float the label, it becomes a block element.

    The simplest solution in your case is to set the label to display: inline-block and add vertical-align: middle to the labels and the inputs. (You might find that the height of the text is such that vertical align won't make any difference anyway.)

提交回复
热议问题