Align text to the baseline of another element's first line of text

时间:2015-05-04 19:44:47

标签: css alignment typography

Is it possible to align the text of one elements to the first line of text of another?

Both elements are variable length, so they might be more than one line.

1 个答案:

答案 0 :(得分:2)

是的,这是可能的。 你应该熟悉flexbox。您正在寻找的css属性是

align-items: baseline

您可以在这里找到有关flexbox的精彩概述: https://css-tricks.com/snippets/css/a-guide-to-flexbox/

我在codepen上构建了一个快速示例: http://codepen.io/durchgemacht/pen/EjVXEW?editors=110