vertical-align: middle doesn't work

前端 未结 4 1304
心在旅途
心在旅途 2020-12-03 09:26

The css property vertical-align: middle does not work in this example.

HTML:

Two line text&l
4条回答
  •  南笙
    南笙 (楼主)
    2020-12-03 09:58

    You must wrap your element in a table-cell, within a table using display.

    Like this:

    Two line text Float right

    and

    .float {
        display: table-cell;
        vertical-align: middle;
        text-align: right;
    }
    .twoline {
        width: 50px;
        display: table-cell;
    }
    div {
        display: table;
        border: solid 1px blue;
        width: 500px;
        height: 100px;
    }
    

    Shown here: http://jsfiddle.net/e8ESb/7/

提交回复
热议问题